Error AtlasError Documentation and Resolution

React Hooks called outside a function component

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

React detected Hook usage outside the body of a function component, which usually means a Hook was called from unsupported code or the Rules of Hooks were broken.

React error #307runtime
Hooks can only be called inside the body of a function component.
  • A Hook is being called in a regular function or unsupported callback.
  • Hooks are used inside conditions, loops, or nested functions.
  • The component structure violates the Rules of Hooks.
  1. Call Hooks only at the top level of a function component or custom Hook.
  2. Move Hook calls out of loops, conditions, event handlers, and nested helpers.
  3. Audit the component for Rules of Hooks violations.
React Docs: Minified React error #307
React error #307 Hooks can only be called inside the body of a function component | Error Atlas