Those are some hot damned beautiful ass fonts on that blog.
As for Hooks, I think their main drawback is it's far too easy to do a whole bunch of business-logic with them. There's a tendency to overuse them for updating state, rather than merely responding to updates of it.
It's not uncommon to see a trampoline of useEffects updating state all over a mildly complicated component, completely betraying the nature of what a component should be: A pure function that represents state as UI, optionally sending events to interested subscribers when the user does something.
While it's falling out of favour due to boilerplate issues, the core idea of Redux sensibly expresses this idea, and solutions to untangle spaghettified business-logic would do well to follow its example.
If you have more than one useEffect in your component, it's probably a signal (no pun intended) that it's time to take a good look at your business-logic and take steps towards lifting it out of there so you can reason about it without worrying about those infernal "rules of hooks".
As for signals themselves, if they don't encourage us to place business-logic in the right place I would guess they will eventually suffer from their own problems. The management of wild state dependency-graphs woven throughout the UI of complex apps, for example.
But hey, if programming were easy everyone would be doing it.
11
u/shuckster Mar 06 '23
Those are some hot damned beautiful ass fonts on that blog.
As for Hooks, I think their main drawback is it's far too easy to do a whole bunch of business-logic with them. There's a tendency to overuse them for updating state, rather than merely responding to updates of it.
It's not uncommon to see a trampoline of
useEffects updating state all over a mildly complicated component, completely betraying the nature of what a component should be: A pure function that represents state as UI, optionally sending events to interested subscribers when the user does something.While it's falling out of favour due to boilerplate issues, the core idea of Redux sensibly expresses this idea, and solutions to untangle spaghettified business-logic would do well to follow its example.
If you have more than one
useEffectin your component, it's probably a signal (no pun intended) that it's time to take a good look at your business-logic and take steps towards lifting it out of there so you can reason about it without worrying about those infernal "rules of hooks".As for signals themselves, if they don't encourage us to place business-logic in the right place I would guess they will eventually suffer from their own problems. The management of wild state dependency-graphs woven throughout the UI of complex apps, for example.
But hey, if programming were easy everyone would be doing it.