Skip to content
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

Promote React.createRef instead of callback refs #180

Closed
cheeZery opened this issue Oct 4, 2018 · 1 comment
Closed

Promote React.createRef instead of callback refs #180

cheeZery opened this issue Oct 4, 2018 · 1 comment

Comments

@cheeZery
Copy link
Contributor

cheeZery commented Oct 4, 2018

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?

@adidahiya
Copy link
Contributor

Sounds like a good idea, but we are closing requests for new rules due to the deprecation timeline: #210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants