1 min readMay 28, 2019
That’s actually by design. Hooks are strictly meant for react components as their only purpose is to “hook” into react API. I’m a little confused by your example though. Why not pass the onclick handler as a prop? Why do you need the hook to be outside the component?