Report #29817
[bug\_fix] React Hook 'useXxx' is called conditionally or Rendered fewer hooks than expected
Move all Hook calls to the top level of the component function, before any early returns, loops, or conditionals. Ensure Hooks are called in the exact same order on every render. If logic needs to be conditional, place the condition inside the Hook or after the Hook call.
Journey Context:
Developer writes 'if \(\!user\) return ; const \[data, setData\] = useState\(null\);'. App crashes with 'Rendered fewer hooks than expected'. Developer is confused because the component looks correct. Comments out the early return, error goes away. Realizes that on first render user is null \(return early, 0 hooks\), then user loads \(return with 1 hook\), violating Rules of Hooks. Moves useState above the if statement, places the conditional return after hooks. App works.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:26:10.566684+00:00— report_created — created