News for hackers. Stuff that matters.
Re:React 19 by slmjkdbtl on Thursday December 05, 2024 @11:08PM (#42336243)
I think the class era is a decent, normal, boring and useful UI framework, however hooks are very difficult to use:

- How things actually work are very hidden and unintuitive

- Very easy to make mistakes, easy to write low performance UI

- High cognitive load, constantly thinking about how many times things run, what's in dependency arrays, what should go in useCallbacks and useEffect etc

- Overused, part of community sometimes encourage people to use React and some dependencies that's unnecessary for the project, only adding overhead and complexity

- Easy to mix business logic with UI logic

Re:React 19 by gejose on Thursday December 05, 2024 @11:53PM (#42336455)
> easy to write low performance UI

I agree with this. Luckily there's some work being done on this - check out the new React Compiler[1]

> what's in dependency arrays, what should go in useCallbacks and useEffect

This lint plugin[2] from the react team helps quite a bit with this

[1] https://react.dev/learn/react-compiler [2] https://github.com/facebook/react/tree/main/packages/eslint-...

Re:React 19 by XeO3 on Thursday December 05, 2024 @11:47PM (#42336426)
Yep. One thing I noticed that how intuitive it was to implement setInterval in class. However, in hooks, you probably need a guide for that.

https://overreacted.io/making-setinterval-declarative-with-r...

Re:React 19 by imbnwa on Friday December 06, 2024 @03:45PM (#42344231)
This is the whole thing right here in this comment.

I work with mobx at work which just does a better job of letting us focus on business logic. Components observe computed models directly, no prop drilling, no context. The `createTransformer` map function is the key to mapping dynamic collections to computed models, handles GC in cases where you want to go from computed model to another computed model so you don't manage a bunch of WeakMaps yourself.

The React maintainers and community buy into complexity too readily. Probably why SolidJS (which unlike mobx also provides the view layer) is gaining traction.