no-unused-state
Full Name in eslint-plugin-react-x
react-x/no-unused-state
Full Name in @eslint-react/eslint-plugin
@eslint-react/no-unused-state
Features
🔍
Presets
core
recommended
recommended-typescript
recommended-type-checked
What it does
Warns unused class component state.
Examples
Failing
import React from "react";
class Example extends React.Component {
// Unused
state = {
foo: 1,
};
render() {
return null;
}
}
Passing
import React from "react";
class Example extends React.Component {
state = {
foo: 1,
};
render() {
return this.state.foo;
}
}