# no-will-update-set-state

Rule `react/no-will-update-set-state`. Disallow usage of setState in componentWillUpdate

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

## Linters

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

## Code examples

### Incorrect: the rule reports this

```jsx
var Hello = createReactClass({
  componentWillUpdate: 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({
  componentWillUpdate: function() {
    this.props.prepareHandler();
  },
  render: function() {
    return <div>Hello {this.props.name}</div>;
  }
});
```

```jsx
var Hello = createReactClass({
  componentWillUpdate: function() {
    this.prepareHandler(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-will-update-set-state": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "react"
  ],
  "rules": {
    "react/no-will-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% |

## Related rules

- [react/jsx-props-no-spreading](https://lintradar.dev/rules/react/jsx-props-no-spreading.md): Disallow JSX prop spreading
- [react/state-in-constructor](https://lintradar.dev/rules/react/state-in-constructor.md): Enforce class component state initialization style
- [react/jsx-boolean-value](https://lintradar.dev/rules/react/jsx-boolean-value.md): Enforce boolean attributes notation in JSX
- [react/default-props-match-prop-types](https://lintradar.dev/rules/react/default-props-match-prop-types.md): Enforce all defaultProps have a corresponding non-required PropType
- [react/function-component-definition](https://lintradar.dev/rules/react/function-component-definition.md): Enforce a specific function type for function components
- [react/destructuring-assignment](https://lintradar.dev/rules/react/destructuring-assignment.md): Enforce consistent usage of destructuring assignment of props, state, and context

---

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