Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

correctness.ui

Do not mutate React state directly

Assigning to `this.state` bypasses React change detection and produces stale UI.

#Metadata

Rule ID
ts.react.no-direct-state-mutation
Severity
high
Confidence
0.88
Languages
javascript, typescript
Presets
recommended, strict
Stability
experimental
Applies to
function
Tags
react, rules-catalog, ui

#Why it matters

State updates must flow through setState or hooks so React can schedule renders and enforce immutability guarantees.

#Remediation

Call setState with the next value or replace the state object immutably instead of assigning into this.state.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/typescript/ts.react.no-direct-state-mutation.rule.yaml.