Rules of Hooks
The two rules for hooks: call them only at the top level, never in conditions, loops or nested functions, and only from React components or custom hooks.
In more detail
Breaking them makes React pair hooks with the wrong stored state. The eslint-plugin-react-hooks plugin catches violations, and to run a hook conditionally you move the condition inside it, such as an early return inside an Effect.
Related terms
- React hook — A function whose name starts with use, such as useState or useEffect, that lets a React component keep state or run side work.
- hook list — The ordered list React stores on each fiber, holding one record for every hook the component called during render.
- eslint-plugin-react-hooks — The official ESLint plugin that checks React code for Rules of Hooks violations and incomplete dependency arrays.
- Rules of React — The official rules React code must follow: components and hooks are pure, React calls components and hooks, and the Rules of Hooks apply.
Taught in
- Rules of Hooks: Call Order, Hook Lists, And Fiber Storage — React 19 & Modern Component Architecture
- The use() Hook: Reading Promises And Context Directly — React 19 & Modern Component Architecture