-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Accessing <Link>'s underlying node via innerRef
#5294
Conversation
Use case: [`react-measure`](https://github.com/souporserious/react-measure): I'd like to show a tooltip above a Link. For this I need to know the underlying DOM node's position. Proxying the `ref` via an `innerRef`-prop would allow to do this. (I stole the naming from [`glamorous`](https://github.com/paypal/glamorous#innerref)) This would allow to extract the position like this: ```jsx <Measure bounds>{({measureRef}) => <Link to="..." innerRef={measureRef}/> }</Measure> ``` Happy to adapt docs in this PR if you think this is worthwhile :)
innerRef
innerRef
Mind adding some sort of test for this? Doesn't need to be anything elaborate. Thanks! |
Alright, just added a test and updated the docs. Let me know if there's anything I've missed! |
Thanks! LGTM. Since it's a pretty minor change, I'll just merge it in. |
@timdorr @danielberndt Do you plan to release this feature in a minor version any time soon? We need that feature to focus |
Waiting on a good time to roll up a minor release. We probably want to coincide with React 16. |
This is released now I'm assuming? |
Ah yeah, there it is https://github.com/ReactTraining/react-router/releases/tag/v4.2.0 |
Use case:
react-measure
:I'd like to show a tooltip above a Link. For this I need to know the underlying DOM node's position. Proxying the
ref
via aninnerRef
-prop would allow to do this. (I stole the naming fromglamorous
)This would allow to extract the position like this:
But I'm optimistic that other use-cases might benefit from accessing the inner ref as well!
Happy to adapt docs (and tests) in this PR if you think this is worthwhile 🙂