react icon indicating copy to clipboard operation
react copied to clipboard

:copilot: `ref` can be overridden by prop spread in React 19

Open joshblack opened this issue 2 months ago • 0 comments

When looking into React 19 changes, it appears that ref can now be overridden by prop spread patterns which can cause unexpected behavior. Investigate the codebase and make sure that we are not accidentally spreading props where a ref could now be passed.

Pattern fixed:

// Before (incorrect)
const Component = forwardRef((props, ref) => (
  <Child ref={ref} {...props} />
))

// After (correct)
const Component = forwardRef((props, ref) => (
  <Child {...props} ref={ref} />
))

If necessary, refs should be merged.

joshblack avatar Nov 05 '25 18:11 joshblack