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 class ExampleExample extends React.class React.Component<P = {}, S = {}, SS = any>Component {
  
Example.state: {
    foo: number;
}
state
= {
foo: numberfoo: 1, }; // Unused Example.render(): nullrender() { return null; } }

Passing

import React from "react";
 
class class ExampleExample extends React.class React.Component<P = {}, S = {}, SS = any>Component {
  
Example.state: {
    foo: number;
}
state
= {
foo: numberfoo: 1, }; Example.render(): numberrender() { return this.
Example.state: {
    foo: number;
}
state
.foo: numberfoo;
} }