Skip to content

react/no-find-dom-node Correctness

This rule is turned on by default.

What it does

This rule disallows the use of findDOMNode.

Why is this bad?

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.

Example

jsx
class MyComponent extends Component {
  componentDidMount() {
    findDOMNode(this).scrollIntoView();
  }
  render() {
    return <div />;
  }
}

References

Released under the MIT License.