Rules
no-direct-mutation-state
Full Name in eslint-plugin-react-x
Full Name in @eslint-react/eslint-plugin
Features
🔍
Presets
core
recommended
recommended-typescript
recommended-type-checked
What it does
Disallows direct mutation of this.state
.
NEVER mutate this.state
directly, as calling setState()
afterwards may replace the mutation you made. Treat this.state
as if it were immutable.
The only place that's acceptable to assign this.state
is in a class component's constructor
.