Re:The self-fulfilling prophecy of React
by uxcolumbo on Friday September 09, 2022 @06:43AM
(#32777638)
> because they are still thinking in terms of state transitions instead of declarative states
Do you have any links where I could read more about this? Or examples?
Re:The self-fulfilling prophecy of React
by madacol on Friday September 09, 2022 @10:39AM
(#32779814)
I think what you are describing looks a lot like what the Svelte team is trying to achieve with the reactive assignments "$:"
A couple years ago, that feature used to work similar as useEffect, so I got used to use it for transitions, and now is biting my ass because the Svelte team are breaking my transition use-cases
It's not a fault in the framework, it's a fault in their understanding, where they don't know how to implement features in O(N) lines of code instead of O(N^2).
The hint is in the name: you're supposed to think in terms of formal functional Effects that mount and unmount independently and compose orthogonally.
The result will be a code base that remains maintainable even though you've kept on adding more nuanced features over months and months.
Also, your snippet doesn't cause an infinite loop at all because modifying local variables does not trigger a rerender. If you had written setA / setB, sure, it would... but I think this perfectly illustrates the explicit vs implicit distinction.
Great frameworks don't trap developers in local maxima.