Error AtlasError Documentation and Resolution

Invalid hook call

Invalid hook call. Hooks can only be called inside of the body of a function component.

React detected a hook being used outside of a valid function component or custom hook context.

React error #418runtime
Invalid hook call. Hooks can only be called inside of the body of a function component.
  • Hooks were called inside a class component or non-component function.
  • Hooks were used conditionally or inside loops.
  • Multiple versions of React are installed in the project.
  • React and React DOM versions are mismatched.
  1. Ensure hooks are only called at the top level of function components or custom hooks.
  2. Remove conditional or loop-based hook usage.
  3. Check for duplicate React installations using npm ls react.
  4. Align react and react-dom versions.
React Docs: Invalid Hook Call Warning
React invalid hook call error: causes and fixes | Error Atlas