Having recently worked on two legacy apps -- one ASP.NET, one Angular -- it made me deeply appreciate React and how far UI tech has come. Phenomenal work from the React team on more optimizations via this compiler. Good article too.
Having recently worked on two legacy apps -- one ASP.NET, one Angular -- it made me deeply appreciate React and how far UI tech has come. Phenomenal work from the React team on more optimizations via this compiler. Good article too.
"that's it" does not paint the full picture. Yes, UI = function(state) is very convenient but the way React implements it inverts the problem. Now instead of having to figure out ways of updating everything you have to go through numerous hoops to get only the things you need to update.
> export default memo(ExampleComponent)
That's literally the point of React Compiler
- Preact (like react, but tiny)
- Solid (like react, but tiny and without the stupid re-rendering, or the stupid rules of hooks)
- Lit (like react; but tiny, based on the browser-native web components, and with a class-based api)
Considering that React has a virtual dom, a separate templating language (jsx), and now also a compiler, I would not call it simple.
I ended up rolling my own state management that lets you just write a normal JS class with normal fields and methods and use that for accessing and modifying your state. No reducers, atoms, stores, etc... Just a JS class for your state and logic.
I've got the feeling that I can render anything I want the way I want with React (even 3-d worlds!) but the only framework that comes close to what my old systems could do is
https://mobx.js.org/README.html
and I cannot understand why MobX isn't more popular than it is. (Worked fine for a websocket-based app to control my smart speakers, it was trivial to make it so adjusting the speaker volume through the mobile app or buttons was reflected on my web app. Never tried a bigger app)
Our bottleneck was that we have so much data, making it all observable up front led to slow initial load times and high memory usage. We now make things observable on demand which has eliminated a lot of that.
I miss it when working with languages other than JavaScript.
1. They can easily provide derived data without manual memoization.
2. You can provide custom setters that do more than just assign values.
3. Your UI only re-renders the parts that reference fields that changed, not every component.
4. Atoms compose nicely etc.
Putting plain JS objects in context/state and passing them around only really works for simple, small apps. Beyond that you need more powerful tools. I also like Zustand for this.
Zustand looks a bit better but it is still very different from normal JS. Nobody writes code like that normally. Why can't we have normal, boring code for state management?
https://github.com/Facepunch/react-class-model
7 stars on github? Class objects with decorators? No thanks.
What's wrong with decorators? Technically not needed but I like things being explicit.
React has yet another templating language.
Sounds like we agree that JS isn't a shitty programming language, but that's hardly unique to react.