DEV Community

Discussion on: How to use React forwardRef

Collapse
 
renatobentorocha profile image
Renato Rocha

Hello z2lai, thanks by comment.

I implemented the example in this post for you to see: github.com/renatobentorocha/forwar....

The useRef hook is used to persist an object reference even after a component to be rerendered: reactjs.org/docs/hooks-reference.h...

Collapse
 
z2lai profile image
z2lai

Hey Renato, thanks so much for the response! Your example convinced me that there was something else that was wrong in my app. It turns out that my "forwardRef(Input);" was wrapped in another HOC that was not passing in ref as the extra second argument. So I removed the HOC and now it works, thanks a lot for your help!