Conceptual
Login

Rules of Hooks

Hooks must be called unconditionally, in the same order, at the top level of a component or custom hook, because React matches each call to stored state purely by call index in a per-fiber linked list. A hook inside an if or loop shifts every later hook onto the wrong slot, corrupting state silently.

This Concept is waiting for its first lesson!

Hooks must be called unconditionally, in the same order, at the top level of a component or custom hook, because React matches each call to stored state purely by call index in a per-fiber linked list. A hook inside an if or loop shifts every later hook onto the wrong slot, corrupting state silently.

Are you a teacher? Sign in to start contributing.

Sign In