by kaoD · 1y ago · 0 comments
You have to opt-in to prop-diffing conditional re-renders (which I wouldn't call a "reactivity engine" either) per component, via React.memo.
And then you also have to opt-in to prop memoization for non-primitives for the prop-diffing not to be useless.
These re-renders might not result in any actual DOM changes since there is an additional vDOM diffing step from the resulting render (which, again, I wouldn't call a "reactivity engine").
https://en.wikipedia.org/wiki/Reactive_programming
https://en.wikipedia.org/wiki/Functional_reactive_programmin...
Which I think React doesn't really fit. React is not about data streams, nor about inferred dependencies.
> Technically you could just getElementById and update it, but react has what I call a whole "reactivity engine" to do it for you.
I would call that "declarative", not "reactive".
https://en.wikipedia.org/wiki/Declarative_programming
The closest thing to reactivity React has are dependency arrays in `useCallback` but I'd say it's a stretch to call that reactive programming.
Compare it with SolidJS's data flow. https://docs.solidjs.com/ Also notice how "reactive" is all over their landing page while React doesn't mention "reactive" at all https://react.dev/
Whereas other frameworks have a full blown reactivity system with signals (basically implicit observables), so your state values are not just regular javascript objects but either proxies or some other object which can be tracked by access in components to update things granularly, eg. setting an elements innerText but automatically.