Skip to content

Conversation

@constayush
Copy link

@constayush constayush commented Dec 22, 2025

In React 19, ref is no longer a special property on the element, Its just a normal prop so we have to do children.props.ref not children.ref

fixes: #3428

In React 19, ref is no longer a special property on the element, Its just a normal prop so we have to do "children.props.ref" not  children.ref
@constayush constayush changed the title fixRefactor ref handling in PopChild component fix: Refactor ref handling in PopChild component Dec 22, 2025
@mattgperry
Copy link
Collaborator

mattgperry commented Dec 22, 2025

Thanks for the PR! How does this work with React 18?

@constayush
Copy link
Author

constayush commented Dec 22, 2025

Thanks for the PR! How does this work with React 18?

Thanks for reviewing, earlier fix won't work with React 18. I've updated the PR to be backwards compatible by adding nullish coalescing.

In React 19, ref is now a regular prop instead of a special property
Updated PopChild to check both children.ref of React 18 and 
children.props.ref of React 19 for backwards compatibility.
@NoelDeMartin
Copy link

@constayush Maybe it should read from props?.ref before trying to do .ref? I'm pretty sure the issue I opened would still get triggered with this code, because when reading .ref you don't get undefined, it throws an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] React 19 refs

3 participants