string `refs` are considered legacy
See original GitHub issueAccording to the official documentation, string refs
will likely be deprecated in the future, and callback refs
are preferred.
Although string refs are not deprecated, they are considered legacy, and will likely be deprecated at some point in the future. Callback refs are preferred.
Cf. https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Why are String Refs legacy?
We advise against it because string refs have below issues, and are considered legacy. String refs were removed in React v16.
Read more >Why ref='string' is "legacy"? - reactjs
String refs don't work with static analysis like Flow. Flow can't guess the magic that framework does to make the string ref “appear”...
Read more >String refs are considered legacy #141
We advise against it because string refs have some issues, are considered legacy, and are likely to be removed in one of the...
Read more >Why are string refs considered legacy in React?
Although string refs are not deprecated, they are considered legacy, and will likely be deprecated at some point in the future.
Read more >Refs and the DOM
Refs provide a way to access DOM nodes or React elements created in the render ... against it because string refs have some...
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
Bumping this React 16.2 is out and this might be changing in 16.3 with the introduction of
React.createRef()
and deprecation is apparently “scheduled” for 16.4 (source).https://reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs
Hello, this warning is constantly showing in all these components. I don’t know when will it be definitely deprecated, but it kind of bothers to see these warnings poping up.
Would you please consider uppering this issue’s priority?
Here is the warning message:
Warning: Component “DatePicker” contains the string ref “input”. Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref
Thanks in advance!