Hacker News new | ask | show | jobs
by hazza1 2658 days ago
Hooks solve some problems nicely, the main killer for me is that they don't work with classes, so you end up with 2 wildly different paradigms in your codebase.

Feels like hooks should have been a clean start in a new framework rather than retrofitted into React.

2 comments

I have a hard time grasping this concern. How your codebase ends up depends on how you set it up. The introduction of hooks doesn't magically replace half of your class components with functions using hooks. You can introduce them when and how you want to introduce them.

On the other hand, people who are fine with having state managed both via class components and via hooks (and why shouldn't they be?) can gradually introduce the concept and refactor existing components as needed, if and when they see some advantage in using hooks at all.

If you don't want milk with your coffee, it's not a problem that there's a pitcher of milk at the table.

Custom hooks encapsulate logic so you can no longer use it in all of your app
This small library [1] let's you use hooks in classes. Probably has some bugs but may be good for a transition period

https://github.com/kesne/with-react-hooks