---
title: "forwardRef is no longer needed: passing ref as a prop in React 19"
description: "In React 19, function components receive ref as an ordinary prop, so you can drop forwardRef. Learn how to migrate, type it in TypeScript and avoid the common traps."
url: https://www.danny.engineering/answer/react/forwardref-is-no-longer-needed-passing-ref-as-a-prop-in-react-19
author: Danny
published: 2026-11-27T00:00:00.000Z
updated: 2026-11-27T17:23:00.000Z
tags: ["React"]
---

# forwardRef is no longer needed: passing ref as a prop in React 19

## The short answer


From React 19, a function component receives `ref` as a normal prop. Remove the `forwardRef` wrapper and read `ref` from props like any other value. `forwardRef` still works for now, but the React docs say it will be deprecated in a future release.


```diff
-const TextInput = forwardRef(function TextInput(props, ref) {
-  return <input ref={ref} {...props} />;
-});
+function TextInput({ ref, ...props }) {
+  return <input ref={ref} {...props} />;
+}
```


## Why it happens


Before React 19, `ref` was a reserved name, just like `key`. React removed it from the props object before your component ran, so a component that wanted to pass a ref down to a DOM element had no way to see it. `forwardRef` was the workaround: it gave your component a second argument that held the ref.


React 19 stops treating `ref` specially for function components. It now arrives in props, so the extra wrapper is unnecessary. A few related changes came with it:

- `key` is still reserved and is not passed as a prop.
- Class components are unchanged. A `ref` on a class component still points to the class instance.
- Reading `element.ref` on a JSX element is deprecated; the value now lives in `element.props.ref`.

## How to fix it


### Read ref from props


```typescript
function SearchBox({ ref, placeholder }) {
  return <input ref={ref} type="search" placeholder={placeholder} />;
}

function Toolbar() {
  const inputRef = useRef(null);

  return (
    <>
      <SearchBox ref={inputRef} placeholder="Search" />
      <button onClick={() => inputRef.current?.focus()}>Focus</button>
    </>
  );
}
```


`useImperativeHandle` works the same way. Pass it the `ref` prop instead of the second `forwardRef` argument.


### Type it in TypeScript


Add `ref` to your props type. If your component wraps a DOM element, `React.ComponentProps` for that element already includes it:


```typescript
type TextInputProps = React.ComponentProps<'input'> & {
  label: string;
};

function TextInput({ label, ref, ...props }: TextInputProps) {
  return (
    <label>
      {label}
      <input ref={ref} {...props} />
    </label>
  );
}
```


For a custom shape, declare it yourself with `ref?: React.Ref<HTMLInputElement>`. Make sure `@types/react` is on version 19 so the types match the runtime.


### Run the codemod


The React team publishes a codemod that removes `forwardRef` and moves the ref into props:


```bash
npx codemod@latest react/19/remove-forward-ref --target src
```


Review the diff afterwards, especially components that combine `forwardRef` with `memo` or generics.


### Keep forwardRef if you support React 18


If you publish a component library that still supports React 18, keep `forwardRef` for now. In React 18, `ref` is still stripped from props, so the new pattern would silently receive `undefined`.


## Common pitfalls

- Keeping a custom prop such as `innerRef` or `inputRef` purely to work around the old limitation. You can now call it `ref`, which is what users of your component expect.
- Forgetting `memo`. Instead of `memo(forwardRef(...))`, write `memo(function Input({ ref, ...props }) ...)`; the ref is passed through.
- Implicit returns in callback refs. React 19 lets a callback ref return a cleanup function, so TypeScript now rejects arrow functions that return a value, such as `ref={(node) => (current = node)}`. Use a block body: `ref={(node) => { current = node; }}`.
- Expecting class components to change. They still need the instance ref, and you cannot read `ref` from their props.
- Mixing versions. If React and `@types/react` are on different major versions, you get confusing type errors about `ref`.

## Related reading

- [React 19: ref as a prop](https://react.dev/blog/2024/12/05/react-19#ref-as-a-prop)
- [React: forwardRef reference](https://react.dev/reference/react/forwardRef)
- [React 19 upgrade guide](https://react.dev/blog/2024/04/25/react-19-upgrade-guide)
