Function components cannot be given refs

React ErrorRefs WarningCommonLast updated: June 28, 2026Tested on:React v19.0Next.js 16June 2026

A ref was attached to a function component that does not support forwardRef.

Function components cannot be given refs Quick Fix⏱️ Est. Fix Time: 2–5 minutes

Usually happens because:

  • ref prop passed to standard function component
  • React version is below 19 without forwardRef

🔍 Quick Checklist:

📊 Where this usually happens (estimated occurrence)

Missing forwardRef wrapper80%
Incorrect ref parameter propagation20%

What is Function components cannot be given refs?

Function components do not have instances, so they cannot receive refs. Attempting to pass a ref prop to a function component fails unless the component is wrapped in React.forwardRef().

Common Causes

  • Passing refs to standard custom function components.

Common Mistakes

  • Expecting standard function components to yield reference nodes without declaring ForwardRef bindings.

How to Fix

1Wrap target child components inside React.forwardRef() to expose inner elements.
2Assign refs directly to underlying HTML nodes inside elements.

Framework-Specific Examples

No framework examples required for this informational status.

Wrong: Ref on Custom Function Component

HTTP Request
const CustomInput = () => <input />;

function Parent() {
  const inputRef = useRef();
  return <CustomInput ref={inputRef} />;
}

Correct: forwardRef Wrapper

HTTP Response
import { forwardRef } from 'react';

const CustomInput = forwardRef((props, ref) => (
  <input ref={ref} {...props} />
));

function Parent() {
  const inputRef = useRef();
  return <CustomInput ref={inputRef} />;
}

Best Practices

  • Apply ForwardRef wrappers on custom input elements.

Frequently Asked Questions (FAQ)

Q: Why do function components reject refs?

Unlike class components, function components do not have instances in memory, meaning there is no backing object for a ref to bind to.

Q: Can I use useImperativeHandle?

Yes. In conjunction with `forwardRef`, `useImperativeHandle` allows you to customize the instance value that is exposed to parent components.

Q: What is the behavior in React 19?

React 19 removes the need for `forwardRef`. In React 19, function components can receive refs directly as normal props.

Q: Does this warning crash the browser?

No. It is a console warning, but the ref object will resolve to `undefined` or `null` inside the parent.

Still having this problem?

Didn't solve your problem?

SuggestRequest Error