no-component-will-receive-props
Replaces usage of 'componentWillReceiveProps' with 'UNSAFE_componentWillReceiveProps'.
Full Name in eslint-plugin-react-x
react-x/no-component-will-receive-propsFull Name in @eslint-react/eslint-plugin
@eslint-react/no-component-will-receive-propsFeatures
🔄
Presets
x
recommended
recommended-typescript
recommended-type-checked
strict
strict-typescript
strict-type-checked
Rule Details
This API was renamed from componentWillReceiveProps to UNSAFE_componentWillReceiveProps. The old name has been deprecated. In a future major version of React, only the new name will work.
Examples
Using the legacy lifecycle method name in class components
React has renamed componentWillReceiveProps to UNSAFE_componentWillReceiveProps. The old name will no longer work in future versions.
import React from "react";
// Problem: Continuing to use the deprecated componentWillReceiveProps
class MyComponent extends React.Component {
componentWillReceiveProps() {
// ...
}
}import React from "react";
// Recommended: Use UNSAFE_componentWillReceiveProps instead
class MyComponent extends React.Component {
UNSAFE_componentWillReceiveProps() {
// ...
}
}