Dan Abramov
Jan 4 · 1 min read

This is a misunderstanding — you absolutely can call Hooks from JS functions that aren’t components. Code reuse is the whole point of Hooks!

However, it would be confusing if random functions could “hide” a Hook call deep inside the call stack. This is why we strongly suggest to name any function using a Hook with “use” convention (e.g. useMyCustomThing). We’re calling such functions “custom Hooks” but again, this is purely a convention so that you can tell whether something is a Hook from a glance.

I suggest to check out the documentation:

It provides you with details on both using and declaring your own Hooks.

Additionally, I explained more about motivation and their mechanics here:

Cheers!

    Dan Abramov

    Written by

    Working on @reactjs. Co-author of Redux and Create React App. Building tools for humans.

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade