Promote React.createRef instead of callback refs
cheeZery opened this issue · comments
From the rules section of the README.md
jsx-no-string-ref
Passing strings to the ref prop of React elements is considered a legacy feature and will soon be deprecated. Instead, use a callback.
Not only is the anchor in the link outdated (should be https://reactjs.org/docs/refs-and-the-dom.html#callback-refs instead of https://reactjs.org/docs/refs-and-the-dom.html#the-ref-callback-attribute), but this linter should also encourage the use of the React.createRef()
API introduced in React 16.3 instead of the callback, see https://reactjs.org/docs/refs-and-the-dom.html#creating-refs.
Maybe there even should be a new linter rule for this, to prevent you from using the callback style? Or the other way around, something like prefer-create-ref
, to prevent string and callback refs?
Sounds like a good idea, but we are closing requests for new rules due to the deprecation timeline: #210