JS.REACT.NO.UNUSED.CLASS.COMPONENT.METHODS

Prevent declaring unused methods of component class

Warns you if you have defined a method or property but it is never being used anywhere.

Rule Details

The following patterns are considered warnings:

Copy
class Foo extends React.Component {
  handleClick() {}
  render() {
    return null;
  }
}

The following patterns are not considered warnings:

Copy
class Foo extends React.Component {
  static getDerivedStateFromError(error) {
    return { hasError: true };
  }
  action() {}
  componentDidMount() {
    this.action();
  }
  render() {
    return null;
  }
}
});

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/