DocumentationRulesno-unused-class-component-members

no-unused-class-component-members

Rule category

Correctness.

What it does

Warns unused class component methods and properties.

Examples

Failing

import React from "react";
 
class Example extends React.Component {
  handleClick() {} // Unused
  render() {
    return null;
  }
}

Passing

import React from "react";
 
class Example extends React.Component {
  static getDerivedStateFromError(error: React.ErrorInfo) {
    return { hasError: true };
  }
  action() {}
  componentDidMount() {
    this.action();
  }
  render() {
    return null;
  }
}