Fix · Pages, phones and Arabic
React: Invalid hook call
What you may see
- The console says hooks can only be called inside a function component
Most likely cause
A hook is used outside a component, inside a condition or loop, or two copies of React are installed.
Check first (about two minutes)
- Run npm ls react: is there more than one version?
The fix prompt
What you type here never leaves your browser. The search runs on this page, and nothing is sent to a server or to an AI.
Kept only in this browser, on this device. Keys and passwords are removed before anything is saved.
Prompt language
Paste it into Claude, ChatGPT, Gemini or Cursor, then follow what it says.
After you tried it, did it work?
Steps
- Show the component and where the hook is called.
- Move hooks to the top of function components, never inside if or loops.
- If two copies of React exist, align versions so only one is installed.
Do not do this
- Do not install React twice.
- Do not turn components into classes to avoid it.