DEV Community

Discussion on: What's hard about React Hooks for you?

Collapse
 
chase2981 profile image
Chase Gibbons • Edited

I personally love hooks but I don’t love custom hooks. The whole reason we love hooks is cuz once you know the basic hooks and how they are supposed to be used, (I.e. useEffect, useState, useCallback, etc) then you can do some really powerful things in a simple manner which is really simple and easy for everyone to understand. All components have a similar flow to them and it makes everything really easy to follow even for new developers—which is huge for code maintainability. However, once you start adding custom hooks every time you want to share something between 2 components—now the amount of hooks you need to know to be productive grows exponentially and the code becomes a lot less readable for a lot of people—and therefore it becomes a lot harder to easily digest and understand. After all, each hook, custom or not, must start with use{HookName}. And so it’s kinda tough to even make the names of your custom hooks highly verbose and readable. Plus, normally I just skip right over a one line hook when looking for where the meat of the code actually resides, then I have to do a double or triple take in other to realize oh, it’s in this custom hook only used in one or two places, lovely :/