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

findDomNode is deprecated #9043

Closed
Abhi347 opened this issue Oct 11, 2019 · 3 comments · Fixed by #9124
Closed

findDomNode is deprecated #9043

Abhi347 opened this issue Oct 11, 2019 · 3 comments · Fixed by #9124

Comments

@Abhi347
Copy link
Contributor

Abhi347 commented Oct 11, 2019

🐛 Bug Report

In the example here, the test uses React.findDomNode(), however, according to React docs React.findDomNode() is deprecated and usage of refs are recommended at its place. Here's what it says -

findDOMNode is an escape hatch used to access the underlying DOM node. In most cases, use of this escape hatch is discouraged because it pierces the component abstraction. It has been deprecated in StrictMode.

Additionally, ESLint has a rule against it's usage, due to this discussion started by Dan Abramov. So we should probably update the example to remove its usage?

To Reproduce

Steps to reproduce the behavior: Write a test using the example and see that eslint gives you a warning with most of the presets (I am using airbnb-base though)

Expected behavior

The example should not use findDomNode, or if it's required then a comment explaining it and providing a way to disable the warning should be there (eslint-disable)

envinfo

System:
    OS: macOS 10.14.5
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  Binaries:
    Node: 11.15.0 - ~/.nvm/versions/node/v11.15.0/bin/node
    Yarn: 1.17.3 - ~/.nvm/versions/node/v11.15.0/bin/yarn
    npm: 6.11.3 - ~/.nvm/versions/node/v11.15.0/bin/npm
@thymikee
Copy link
Collaborator

Yes please, would you like to fix it? :)

@Abhi347
Copy link
Contributor Author

Abhi347 commented Oct 11, 2019

Yes please, would you like to fix it? :)

Sure, I'd love to :-)

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants