Unable to forwardRef
See original GitHub issueThe proper way of passing ref in React is this ref={ref}
but Cleave supports only the older approach htmlRef={r => ref=r}
.
But this is not sufficient for forwarding refs (docs)
The workaround I am doing is this: htmlRef={r => ref && (innerRef.current = r)}
but that’s not right and it’s throwing lint error because current
should be read-only
The desired state is to be able do this htmlRef={innerRef}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:20
- Comments:5
Top Results From Across the Web
Unable to get `forwardRef` utility method to document properly
I'm using forwardRefWithAs (a fn defined in @reach/utils) in a component library and using react-docgen-typescript with Storybook to ...
Read more >Unable to style component using forwardRef - Stack Overflow
The reason the style is disappearing is that you've defined your Test component inside your App component. That means that every time App ......
Read more >Forwarding Refs - React
Ref forwarding is an opt-in feature that lets some components take a ref they receive, and pass it further down (in other words,...
Read more >error warning: function components cannot be given refs ...
Iget error 'Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?' . How...
Read more >Using forwardRef in React to clean up the DOM
In this tutorial, we'll review the concept of forwarding refs in React and how it helps us manage interactions with the DOM.
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
Would be great to have a suggested/working solution for this - running into the same issue with forwarding refs and useRef.
A solution that worked for me: