Error AtlasError Documentation and Resolution

Function components cannot have string refs

Function components cannot have string refs. We recommend using useRef() instead.

React threw this error because a string ref was attached to a function component. String refs are legacy behavior and are not supported on modern function-component patterns.

React error #309runtime
Function components cannot have string refs. We recommend using useRef() instead.
  • Legacy string refs were used on a function component.
  • Older class-component ref patterns were copied into a function-component implementation.
  • A wrapper component passed a string ref into a component tree that now uses hooks.
  1. Replace the string ref with `useRef()` in the parent component and pass the ref object correctly.
  2. Use a callback ref if the ref needs custom assignment logic.
  3. If the child component needs to expose a DOM node or imperative API, use `forwardRef`.
React Docs: Minified React error #309
React error #309 function components cannot have string refs: causes and fixes | Error Atlas