Permalink
55b9cbe Jul 18, 2016
34 lines (26 sloc) 777 Bytes

Prevent usage of findDOMNode (no-find-dom-node)

Facebook will eventually deprecate findDOMNode as it blocks certain improvements in React in the future.

It is recommended to use callback refs instead. See Dan Abramov comments and examples.

Rule Details

The following patterns are considered warnings:

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

The following patterns are not considered warnings:

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