New
Introducing React Bench, see how different models perform on React code

react-doctor/no-impure-state-updater

State updater has side effects

  • Category: Bugs
  • Severity: error
  • Source: oxlint-plugin-react-doctor
  • Framework: global
  • Enabled when: react
  • Default: Enabled

Validation prompt

Use this to decide whether a fired diagnostic is real or a false positive.

Confirm the reported code matches State updater has side effects. Check the framework context and diagnostic message before suppressing it.

Fix prompt

Use this once validation confirms the diagnostic is real.

Keep state updater callbacks pure and return only the next state. Move notifications, storage, timers, ref writes, and other external work into the event or effect that queues the update.

More Bugs rules from the rules reference:

  • react-doctor/no-indeterminate-attribute: Indeterminate checkbox state set as an attribute
  • react-doctor/no-initialize-state: Disallow initializing state in an effect.
  • react-doctor/no-is-mounted: Disallow the removed legacy isMounted() API — cancel async work instead of guarding setState.
  • react-doctor/no-jsx-element-type: Widen the return type from JSX.Element to React.ReactNode: function App(): React.ReactNode
  • react-doctor/no-legacy-class-lifecycles: Move side effects in `componentWillMount` to `componentDidMount`; replace `componentWillReceiveProps` with `componentDidUpdate` (compare prevProps) or the static `getDerivedStateFromProps` for pure state derivation; replace `componentWillUpdate` with `getSnapshotBeforeUpdate` paired with `componentDidUpdate`. The `UNSAFE_` prefix only silences the warning — React 19 removes both forms.