4 ms·
Most state in React isn't exposed because it's managed by the OOP DOM. Scroll positions, focus, press state of buttons, cached bitmaps, autofill state, lists of
by mike_hearn 3y ago
Most state in React isn't exposed because it's managed by the OOP DOM. Scroll positions, focus, press state of buttons, cached bitmaps, autofill state, lists of event handlers etc.
Jetpack Compose now, that is a pure implementation of the React concept all the way to the bottom. And their compiler plugin basically makes the React model a part of the language, so you could go take a look at that if you're interested in language-integrated approaches. There's essentially no OOP there and all state is handled with their useState equivalent. But as I write in another post it actually does suffer badly from that decision, in my view. The combination of the React concept with static typing doesn't mix well at all. There's an astonishing amount of copy/paste coding going on in the Compose landscape and worse, a new generation are starting to learn that this is normal and just the way UI code looks.
On the web the React approach took off due to the history of JS/HTML not really supporting proper componentization or indeed proper OOP until very late (arguably it still doesn't). Then the Android guys decided to adopt it to be more familiar to web devs and as a way to justify the huge expense of starting over, which they did need, the old Android toolkit has a lot of tech debt in it.
But I think we will come to regret that evolutionary path. Once you get past the convenience of being able to add/remove widgets by rebuilding the whole layout from scratch, it's just not a good way to express UI in statically typed languages.
- lmm 3y ago> Most state in React isn't exposed because it's managed by the OOP DOM. Scroll positions, focus, press state of buttons, cached bitmaps, autofill state, lists of event handlers etc. For someone writing stuff in React all that is effectively the "runtime", and whether it's being managed in OOP, FP, or some other fashion is an implementation detail. (You don't e.g. subclass DOM classes when writing React). > The combination of the React concept with static typing doesn't mix well at all. Hasn't been my experience at all, shrug, my main job does a lot of stuff with React in Scala.js and it works very well.