-
Notifications
You must be signed in to change notification settings - Fork 85
lose ref value after rerendering page #133
Comments
I have the same problem. InnerRef just doesn't work |
Solved ! :) Use it like this:
Then, the element can always be accessed using this.textarea.current |
Here is a useRef solution. |
https://codesandbox.io/s/recursing-mendeleev-mcbb3
Before re-rendering, click focus button. It should work. It will focus the textarea.
However, if you click the re-render button, this will cause state to update and the app to rerender and after this, if you click the focus button, it will not focus because the ref is null.
The text was updated successfully, but these errors were encountered: