Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Latest commit

 

History

History
34 lines (27 loc) · 800 Bytes

no-is-mounted.md

File metadata and controls

34 lines (27 loc) · 800 Bytes

Prevent usage of isMounted (no-is-mounted)

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

Rule Details

The following patterns are considered warnings:

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

The following patterns are not considered warnings:

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