# no-unsafe

Rule `react/no-unsafe`. Disallow usage of unsafe lifecycle methods

- Source: react
- Technologies: React
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 31.4K weekly downloads of presets that enable it
- Trend: +32.4% last quarter
- Rank: #1643 by reach, #1083 by growth

## Linters

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

## Code examples

### Incorrect: the rule reports this

```jsx
class Foo extends React.Component {
  UNSAFE_componentWillMount() {}
  UNSAFE_componentWillReceiveProps() {}
  UNSAFE_componentWillUpdate() {}
}
```

```jsx
const Foo = createReactClass({
  UNSAFE_componentWillMount: function() {},
  UNSAFE_componentWillReceiveProps: function() {},
  UNSAFE_componentWillUpdate: function() {}
});
```

### Correct: the rule accepts this

```jsx
class Foo extends Bar {
  UNSAFE_componentWillMount() {}
  UNSAFE_componentWillReceiveProps() {}
  UNSAFE_componentWillUpdate() {}
}
```

```jsx
const Foo = bar({
  UNSAFE_componentWillMount: function() {},
  UNSAFE_componentWillReceiveProps: function() {},
  UNSAFE_componentWillUpdate: function() {}
});
```

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-unsafe": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "react"
  ],
  "rules": {
    "react/no-unsafe": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Alloy](https://lintradar.dev/presets/alloy.md) | ESLint | `eslint-config-alloy` | 166 | 31.4K | +32.4% |

## Related rules

- [react/jsx-no-literals](https://lintradar.dev/rules/react/jsx-no-literals.md): Disallow usage of string literals in JSX
- [react/checked-requires-onchange-or-readonly](https://lintradar.dev/rules/react/checked-requires-onchange-or-readonly.md): Enforce using `onChange` or `readonly` attribute when `checked` is used
- [react/forbid-component-props](https://lintradar.dev/rules/react/forbid-component-props.md): Disallow certain props on components
- [react/forbid-dom-props](https://lintradar.dev/rules/react/forbid-dom-props.md): Disallow certain props on DOM Nodes
- [react/no-did-mount-set-state](https://lintradar.dev/rules/react/no-did-mount-set-state.md): Disallow usage of setState in componentDidMount
- [react/forward-ref-uses-ref](https://lintradar.dev/rules/react/forward-ref-uses-ref.md): Require all forwardRef components include a ref parameter

---

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