# no-did-update-set-state

Rule `react/no-did-update-set-state`. Disallow usage of setState in componentDidUpdate

- Source: react
- Technologies: React
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 4.7M weekly downloads of presets that enable it
- Trend: +3.4% last quarter
- Rank: #1407 by reach, #1544 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `react/no-did-update-set-state` | no | no | package `eslint-plugin-react` | [docs](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-did-update-set-state.md) |
| Oxlint | `react/no-did-update-set-state` | no | no | plugin `react`, category correctness | [docs](https://oxc.rs/docs/guide/usage/linter/rules/react/no-did-update-set-state.html) |

## Code examples

### Incorrect: the rule reports this

```jsx
var Hello = createReactClass({
  componentDidUpdate: function() {
     this.setState({
        name: this.props.name.toUpperCase()
      });
    },
  render: function() {
    return <div>Hello {this.state.name}</div>;
  }
});
```

### Correct: the rule accepts this

```jsx
var Hello = createReactClass({
  componentDidUpdate: function() {
    this.props.onUpdate();
  },
  render: function() {
    return <div>Hello {this.props.name}</div>;
  }
});
```

```jsx
var Hello = createReactClass({
  componentDidUpdate: function() {
    this.onUpdate(function callback(newName) {
      this.setState({
        name: newName
      });
    });
  },
  render: function() {
    return <div>Hello {this.props.name}</div>;
  }
});
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import react from "eslint-plugin-react";

export default [
  {
    plugins: { react },
    rules: {
      "react/no-did-update-set-state": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "react"
  ],
  "rules": {
    "react/no-did-update-set-state": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |
| [React Native](https://lintradar.dev/presets/react-native.md) | ESLint | `@react-native/eslint-config` | 79 | 1.2M | +5.8% |
| [Alloy](https://lintradar.dev/presets/alloy.md) | ESLint | `eslint-config-alloy` | 166 | 31.4K | +32.4% |

## Related rules

- [react/jsx-filename-extension](https://lintradar.dev/rules/react/jsx-filename-extension.md): Disallow file extensions that may contain JSX
- [react/no-unstable-nested-components](https://lintradar.dev/rules/react/no-unstable-nested-components.md): Disallow creating unstable components inside components
- [react/jsx-no-bind](https://lintradar.dev/rules/react/jsx-no-bind.md): Disallow `.bind()` or arrow functions in JSX props
- [react/jsx-fragments](https://lintradar.dev/rules/react/jsx-fragments.md): Enforce shorthand or standard form for React fragments
- [react/jsx-curly-brace-presence](https://lintradar.dev/rules/react/jsx-curly-brace-presence.md): Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes
- [react/jsx-no-script-url](https://lintradar.dev/rules/react/jsx-no-script-url.md): Disallow usage of `javascript:` URLs

---

Web page: https://lintradar.dev/rules/react/no-did-update-set-state. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
