Rules of React visual mental model
The Rules of React protect the assumptions React uses to render, re-render, interrupt, retry, and optimize your components safely.
Components and Hooks should be idempotent for the same relevant inputs and should not perform external side effects during render.
Treat values as read-only for the current render and create next values instead of mutating previous snapshots.
Use components through JSX and Hooks through React component/custom-Hook execution, rather than invoking them as arbitrary functions.
Stable call order lets React associate each Hook call with the correct state and lifecycle slot across renders.
Purity makes rendering restartable
Repeating render does not duplicate purchases, subscriptions, analytics writes, or external mutations.
Side effects belong at explicit boundaries
Calculate UI only.
Perform work caused by a specific user interaction.
Synchronize the rendered component with an external system.
Hook order is positional identity
useState → useContext → useEffect
useState → useContext → useEffect
useState → useEffect → useRef
useState → useRef
React owns component invocation
Direct function calls bypass React's component execution model and can break Hook and identity assumptions.
JSX lets React control when the component executes and how its identity participates in the tree.
Debug rule violations by category
Keep this mental model
Continue with Purity, Immutability and Render Safety for the detailed rules, examples, and debugging guidance.