3 ms·
I just don’t get hooks. People say it’s an easy way to keep your lifecycle events close to the functionality they’re dealing with, but in the end it’s just a cl
by Aeolun 7y ago
I just don’t get hooks. People say it’s an easy way to keep your lifecycle events close to the functionality they’re dealing with, but in the end it’s just a clusterfuck of function calls in the render method.
As far as I’m concerned, dealing with all your lifecycle events in one or two functions makes it much easier to reason about what is going on.
Because hooks look so much like magic, people treat them as magic and when they don’t work as expected, they have no clue why (adding more hooks to solve the problem!). I feel like Reacts’ surface area to shoot yourself in the foot has increased fivefold since the introduction of hooks.
The only thing I found really compelling about hooks is the ability to write shared functionality to include in multiple components, but practically I still have to find the first time I actually need that.
- ratww 7y ago> People say it’s an easy way to keep your lifecycle events close to the functionality they’re dealing with, but in the end it’s just a clusterfuck of function calls in the render method. Maybe the code you work on is a special case, but in my experience that sounds exactly like an opportunity to refactor your code into custom hooks, as you mention in your last paragraph.