3 ms·
I switch to hooks the moment they were in stable. Because functional components are simpler in nature. And the reactive apparatus that hooks are make it simpler
by skydhash 1y ago
I switch to hooks the moment they were in stable. Because functional components are simpler in nature. And the reactive apparatus that hooks are make it simpler to bring external modules. Writing HOC was a pain.
Hooks are a good translation layer.
- bavell 1y agoApparently we are in the minority, but I find hooks great for DRY and composition. My components can be thin and presentational while the business logic is tucked away in neat little packages. Didn't realize how much I disliked class components and HOCs until hooks showed up. Footguns, learning curve? Sure, but I'll still make that trade.
- owebmaster 1y agoTreating one big function handling 10 different scenarios is not what I would call functional components, much less simpler in nature. React in its current incarnation is the best framework to create unmaintainable code.
- skydhash 1y ago> *Treating one big function handling 10 different scenarios is not what I would call functional components, much less simpler in nature. That’s an antipattern. Like the 200 lines function in imperative or the god class in OOP. Your components should be small and composable. Before directly using the standard hooks in the components, you should think first if it would not better to write a custom one. Scenarios should be handled by custom hooks and component should just get data from them. If you cannot test scenarios apart from your views and vice-versa, you’re doing it wrong