3 ms·
Counterpoint: I'm not a junior dev in general, but a couple of years ago I did my first project involving React. I came back to it a year later and was able to
by kqr 4y ago
Counterpoint: I'm not a junior dev in general, but a couple of years ago I did my first project involving React. I came back to it a year later and was able to refactor away much hook usage and make components pure. It greatly simplified the codebase and I wish the documentation would have been more insistent on this back when I used it, so I didn't have to earn the experience on my own.
I guess the redeeming point is that hook usage is usually easy to refactor out, unless it's permeated your architecture somehow.
- Rapzid 4y agoI agree with everything your saying I just disagree with the communication; well and I believe the line I quoted to be utter bollocks. Dealt with projects that had evolved(devolved?) into hook monstrosities. 20-30 hooks in god components each with n-layers of "custom" hooks each permeated with useEffects and useStates chaining off each other causing a rats nest of render loops and maddening re-render puzzles.. It's awful. I'm anti-hook in general and I use them very sparingly. But they, the effect hooks, are integral to React and need to be used to build the vast majority of anything interesting. People will need to use them or use something written by somebody else that used them. To me that's not an "escape hatch" but fundamental to the libraries usefulness.
- kqr 4y agoI think we agree on all points, then. It's difficult to communicate this to beginners in a way that paints an accurate picture. Laud it too highly and it gets overused, downplay it and you fail to communicate a core strength.
- robertoandred 4y agoYou know what they say about blaming tools…
- ihateolives 4y ago> I guess the redeeming point is that hook usage is usually easy to refactor out Yes, but now imagine that you could've done it more or less correct in the first try. Refactors happen, but needing the refactor after it took 2 years for best practices to sink in? I don't think it's an endorsment for the hooks. I refactored my old React app from classes to hooks when hooks became fashionable. Few years later I'm still sure that it's a mess and I've used hooks wrong. Am I itching to refactor again? No way. I let it rot some more, perhaps React will take another sharp turn and I'll save myself time doing it twice.