Rules of Hooks
Multiple Choice Medium
Question
Which of the following violates the Rules of Hooks?
Hint
Hooks must be called in the same order every render.
Explanation
Calling a Hook inside an if statement violates the Rules of Hooks. Hooks must be called at the top level of a component or custom Hook, not inside loops, conditions, or nested functions, so they run in the same order every render.
Related Resources
Related Lessons
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.