Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the same DOM node to use both a callback and a RefObject in its ref prop #14726

Closed
richsilv opened this issue Jan 30, 2019 · 2 comments
Closed

Comments

@richsilv
Copy link

Do you want to request a feature or report a bug? Feature

What is the current behavior?

The ref attribute passed to a DOM node can be either a callback or a RefObject, but not both. Sometimes, that's exactly what's required: for example, a library like react-pose demands ref forwarding to work with a React Component, but you'd also like to retain a reference to the same parent DOM node within that component itself for a different reason. It's often not possible to nest DOM nodes to achieve a similar thing using two different ref attributes as that breaks layout.

Here's a link to a naive attempt to achieve this: https://codesandbox.io/s/4jyw3q3v57

I'm not surprised this doesn't work as there's no reason for the parent ref callback to fire, but I don't know how else to go about it.

What is the expected behavior?

The callback provides the component with its own reference to the parent DOM node, whilst also providing it to the parent component via the passed RefObject.

@eps1lon
Copy link
Collaborator

eps1lon commented Feb 24, 2019

Sounds like a duplicate of #13029.

@richsilv
Copy link
Author

Agreed, closing in its favour.

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

No branches or pull requests

3 participants