Question · JavaScript and React course · Module 5: useEffect and Custom Hooks
Rules of Hooks in React
Why can you NOT call hooks inside conditional statements (if/else)?
Answer options
- React tracks hooks by their call order - conditionally skipping a hook shifts the order and causes errors
- Hooks inside conditions run slower than at the top level
- JavaScript does not allow calling functions inside if/else blocks
- Conditions cause memory leaks in hooks
You can check the correct answer by solving this task in the CodeWorlds game.