JS.REACT.NO.IS.MOUNTED

Prevent usage of isMounted

isMounted is an anti-pattern, is not available when using ES6 classes, and it is on its way to being officially deprecated.

Rule Details

Examples of incorrect code for this rule:

Copy
var Hello = createReactClass({
  handleClick: function() {
    setTimeout(function() {
      if (this.isMounted()) {
        return;
      }
    });
  },
  render: function() {
    return <div onClick={this.handleClick.bind(this)}>Hello</div>;
  }
});

Examples of correct code for this rule:

Copy
var Hello = createReactClass({
  render: function() {
    return <div onClick={this.props.handleClick}>Hello</div>;
  }
});

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/