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)