-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for "string" refs will be deprecated #3468
Comments
We should gradually convert all of these to functional components anyway (which uses "useRef" instead of "createRef"). Here are my personal notes on how to use REFS with functional components: RefsWhy use Refs?By using a ref, you ensure that:
Changing a ref does not trigger a re-render, so refs are not appropriate for storing information you want to display on the screen. Use state for that instead. How to useCall
On the next renders, Changing a ref does not trigger a re-render. This means refs are perfect for storing information that doesn’t affect the visual output of your component. For example, if you need to store an interval ID and retrieve it later, you can put it in a ref. To update the value inside the ref, you need to manually change its
Later, you can read that interval ID from the ref so that you can call clear that interval:
|
Do you want to combine this ref work with functional component work? If so, this issue could be renamed to indicate the much larger task of doing that (and refs would be one small part). Perhaps as a Project, and separate out each component as a separate Issue? |
However you want is fine with me. |
Renderer
v3
Browser
Chrome
Operating System
MacOS
What happened?
React is emitting many of these errors in the browser console:
for the following files:
Anything that looks like
ref='....'
should be changed to usecreateRef()
: More info on old React docs.This might be a good first issue? Maybe not all at once? Nothing is currently broken and likely won't be for awhile. It is annoying seeing the Errors in console, though.
Code
No response
The text was updated successfully, but these errors were encountered: