Automatic ref Forwarding in Function Components
What you'll learn: How React 19 eliminates the need for forwardRef() by allowing function components to receive ref as a regular prop.
The Old Way vs The New Way
Before React 19, if you wanted a parent component to access a DOM element inside a child function component, you had to wrap that component in forwardRef(). This created an extra layer of abstraction and boilerplate.
In React 19, refs are just props. Function components can receive ref directly alongside other props like className or onClick. No wrapper needed.
Why This Matters
Think of forwardRef() like needing a special shipping container for a particular item. React 19 says "actually, that item fits in a regular box just fine." The functionality is identical, but you eliminate the packaging overhead.
Before (React 18 and earlier):
const Input = forwardRef((props, ref) => {
return <input ref={ref} {...props} />;
});
After (React 19):
function Input({ ref, ...props }) {
return <input ref={ref} {...props} />;
}
// Or with destructuring:
function Input(props) {
return <input ref={props.ref} {...props} />;
}
What This Enables
This change makes function components feel more consistent with the rest of React's prop system. ref is no longer a "magic" prop that needs special handling—it's just another value being passed down.
Components written this way work seamlessly with parent components that pass refs, and you can even conditionally use or ignore the ref prop like any other prop.
Key Takeaway: React 19 treats ref as a normal prop in function components, eliminating the forwardRef() wrapper and making component APIs simpler and more predictable.