DEV Community

Harry J Beckwith
Harry J Beckwith

Posted on

Rules of React hooks

Only call React Hooks in React functions.
React component functions and Custom hooks.

Only call React hooks at the Top level.
Don't call them in nested functions.
Don't call them in any block statements.

useEffect: always add everything you refer to inside the useEffect() as a dependency.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay