DocumentationRulesno-unsafe-component-will-receive-props

no-unsafe-component-will-receive-props

Full Name in eslint-plugin-react-x

react-x/no-unsafe-component-will-receive-props

Full Name in @eslint-react/eslint-plugin

@eslint-react/no-unsafe-component-will-receive-props

Features

🔍

Presets

  • core
  • recommended
  • recommended-typescript
  • recommended-type-checked

What it does

Warns the usage of UNSAFE_componentWillReceiveProps in class components.

Why is this bad?

Using unsafe lifecycle methods like UNSAFE_componentWillReceiveProps makes your component’s behavior less predictable and are more likely to cause bugs.

Examples

Failing

import React from "react";
 
class Example extends React.Component {
  UNSAFE_componentWillReceiveProps() {
    // ...
  }
}