question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow usage of ref on custom components

See original GitHub issue

React 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Andaristcommented, Jan 25, 2019

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.

2reactions
clayne11commented, Nov 5, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found