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

> Because they "hook" into the component lifecycle.

For me, "hooks" in other frameworks/libraries that I have encountered don't work like that. Usually, the hook is something static and predefined by the framework/library, and _my_ code attaches to those hooks. The way you explain React hooks sounds like we're _conjuring_ hooks in the components willy-nilly, and then attaching things to them. However, I have never found an explanation for the name "hook" in the official React documentation; the explanation might be somewhere in the documentation, but I never found it.



The majority of third-party hooks that I see use useState, useEffect or useContext, which hook into the React lifecycle of the component they are used in.

If they aren't using one of those (or more rarely one of the other built-in hooks), then they probably don't really need to be hooks and should just be plain functions.




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

Search: