Documentation
Rules
no-unused-state

no-unused-state

Rule category

Correctness.

What it does

Warns unused class component state.

Examples

Failing

import React from "react";
 
class Example extends React.Component {
  state = {
    foo: 1,
  }; // Unused
 
  render() {
    return null;
  }
}

Passing

import React from "react";
 
class Example extends React.Component {
  state = {
    foo: 1,
  };
 
  render() {
    return this.state.foo;
  }
}