Why must React hooks be called at the top level?
Because React tracks hooks by call order. Calling a hook inside a loop or condition changes the order between renders, breaking React's internal tracking and causing state to be assigned to the wrong hook, which causes subtle bugs.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Advanced React Hooks Interview Questions With Answers
useMemo memoizes a value; useCallback memoizes a function reference. Use useMemo for expensive computations and useCallback for stable function references passed to memoized children.
useState is for simple independent state. useReducer is for complex state with transitions, modeling state as a reducer that takes an action. Choose based on complexity and clarity.
For mutable values that should persist across renders without triggering re-renders, like timer ids, previous values, and mounted flags. Mutating current does not trigger a re-render, which differs from useState.
Still have questions?
Browse all our FAQs or reach out to our support team
