Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Never understood why React hooks are such a big deal- I mean you’re just setting state. Or am I missing something?


It seems you are. I'd encourage you to read briefly through [1] that I linked above, it shows why hooks are needed rather than just functions. Basically you're passing state around in a Closure such that you can hook into life cycles from any part of the app. This means that I can create a self contained hook for something like making an animation for a component and making it usable for any component I want, rather than wrapping everything into an AnimationComponent just to get the lifecycle state. I can reuse this behavior anywhere else in the app.


I think the point is you don't have to deal with anything else. You only have to set state!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: