Allow usage of ref on custom components
See original GitHub issueReact 16.3 introduced the concept of forwarding refs as a first-class citizen. We can remove the usage of innerRef
and just use the regular ref
prop. We can make this backwards compatible by using innerRef
if it exists however we shouldn’t throw if a custom component doesn’t have innerRef
- ref
can work just fine.
This library currently breaks with styled-components@4
due to this issue.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:14 (3 by maintainers)
Top Results From Across the Web
useRef() Hook on a custom component - Stack Overflow
I'm assuming that 'ref' works only on html 'pure' tags. Is there any way to use 'useRef' hook in a custom component?
Read more >Refs and the DOM - React
When the ref attribute is used on a custom class component, the ref object receives the mounted instance of the component as its...
Read more >how to get ref of custom component using useRef() in ReactJS
A custom component doesn't expose its DOM nodes by default. if you try to put a ref on your own component, you will...
Read more >How to use `ref` on custom element? · Issue #113 - GitHub
So my question is how to use with a custom element, ... You need to pass ref to the element rendered by the...
Read more >The Complete Guide to useRef() and Refs in React
Updating a reference doesn't trigger a component re-rendering. Now, let's see how to use useRef() in practice. 1.1 Use case: logging button ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Somehow I’ve made a mistake and was calling isForwardRef with wrong argument, I’ve prepared a PR with a fix for this just now.
It was a pain getting the tests working and I ran out of time working on it. I forked it and fixed it at
@clayne/react-waypoint
but the tests are failing so I never submitted a PR.My company Casalova is using it in production and everything works.