close

no-find-dom-node

Configuration

PresetConfigured Value
✅ reactPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, reactPlugin } from '@rslint/core';

export default defineConfig([
  reactPlugin.configs.recommended,
  {
    rules: {
      'react/no-find-dom-node': 'error',
    },
  },
]);

Disallow usage of findDOMNode.

Facebook will eventually deprecate findDOMNode as it blocks certain improvements in React in the future. It is recommended to use callback refs instead.

Rule Details

This rule flags any call whose callee is the identifier findDOMNode (bare call) or a member-access whose property name is findDOMNode (React.findDOMNode(...), ReactDOM.findDOMNode(...), etc.). Computed (bracket) access such as React['findDOMNode'](...) is intentionally not flagged — this mirrors the upstream rule's AST check.

Examples of incorrect code for this rule:

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

Examples of correct code for this rule:

class MyComponent extends Component {
  componentDidMount() {
    this.node.scrollIntoView();
  }
  render() {
    return <div ref={(node) => (this.node = node)} />;
  }
}

Original Documentation