Sticky element `ref` is overwriten
I'm submitting a ...
- [x] bug report
- [x] feature request
- [ ] support request
If you're reporting a bug, please provide a minimal demonstration of the problem
What is the current behavior?
When rendering this Sticky element:
<Sticky>
{
()=> <div ref={console.log('ref was called')}/>
}
</Sticky>
The ref was called is not printed.
Since here the ref prop is overwritten.
What is the expected or desired behavior?
I expect to be able to get a ref to my <div/>
Why do you want this? What use case do you have?
I might need something other than the supplied 'calculatedHeight`.
What is your environment?
- Version:
6.0.3 - Browser:
Chrome
Thanks for the report! Now that React provides a ref forwarding API this is definitely something we could provide. If you wanted to take a stab at it I'd be happy to merge a PR :)
Oh this is an interesting bit from that post, however
When you start using forwardRef in a component library, you should treat it as a breaking change and release a new major version of your library.
That's a good point, if there are people relying on ref returning the instance of Sticky, changing this would break their application. I'm not sure the marginal improvement is worth a major version release at the moment.