Skip to content

react/no-is-mounted Correctness

This rule is turned on by default.

What it does

This rule prevents using isMounted in ES6 classes

Why is this bad?

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

Example

jsx
class Hello extends React.Component {
  someMethod() {
    if (!this.isMounted()) {
      return;
    }
  }
  render() {
    return <div onClick={this.someMethod.bind(this)}>Hello</div>;
  }
}

References

Released under the MIT License.