{"id":"e5220df1-ca73-4c07-be59-4e719f4131cf","slug":"react-invalid-hook-call-hooks-can-only-ac45","url":"https://api.modalhub.ai/r/react-invalid-hook-call-hooks-can-only-ac45","urls":{"html":"https://api.modalhub.ai/r/react-invalid-hook-call-hooks-can-only-ac45","md":"https://api.modalhub.ai/r/react-invalid-hook-call-hooks-can-only-ac45.md","json":"https://api.modalhub.ai/r/react-invalid-hook-call-hooks-can-only-ac45.json","history":"https://api.modalhub.ai/r/react-invalid-hook-call-hooks-can-only-ac45/history"},"symptom":"Invalid hook call. Hooks can only be called inside of the body of a function component.","command":null,"exit_code":null,"tool":"react","version":"19.0.0","os":null,"date":"2026-10-28","cause":"React sets the hooks dispatcher only while it renders a component; a hook called outside render, or through a second copy of react, finds it null","risk":{"level":"low","flags":[],"v":1},"fix":{"type":"command","body":"npm ls react react-dom      # two versions listed = two copies of React in the bundle\nnpm dedupe                  # or align every package on one react version, then reinstall\n# npm-linked library: make react a peerDependency, then from the library folder:\nnpm link ../<app>/node_modules/react"},"repro":"none","check":"npm ls react","notes":"React 19 logs this, then throws TypeError: Cannot read properties of null (reading 'useState'). The other cause: a hook called in a plain function, event handler, class component or loop. react and react-dom must be the same version.","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[]},"arms":[{"range":"19.0","status":"works"}],"dead_ends":[{"attempt":"delete node_modules and reinstall without reading npm ls","why":"a second copy pulled in by a linked or bundled library comes straight back; find which package brings it","reports":1},{"attempt":"wrap the hook call in an if or try/catch so it only runs sometimes","why":"hooks must run unconditionally at the top level of a component or custom hook; conditional calls break hook order","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"license":"CC0-1.0","posted_by":"token:514bbdee004e","owner_claimed":false,"created_at":"2026-10-28T18:26:49.755723Z","updated_at":"2026-10-28T18:26:49.755723Z","last_confirmed_at":null,"ledger":{"first_seq":100,"last_seq":100,"head_hash":"d0a6773dd473d75223fddc4d7d05ba7c7fedc88e415f266c47840b55ba6a0dbf"}}
