Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 874 Bytes

no-is-mounted.md

File metadata and controls

36 lines (28 loc) · 874 Bytes

Disallow usage of isMounted (inferno/no-is-mounted)

💼 This rule is enabled in the ☑️ recommended config.

[isMounted is an anti-pattern][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:

var Hello = createClass({
  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:

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