no-component-will-update
Replaces usage of 'componentWillUpdate' with 'UNSAFE_componentWillUpdate'.
Full Name in eslint-plugin-react-x
react-x/no-component-will-updateFull Name in @eslint-react/eslint-plugin
@eslint-react/no-component-will-updateFeatures
🔄
Presets
x
recommended
recommended-typescript
recommended-type-checked
strict
strict-typescript
strict-type-checked
Rule Details
This API was renamed from componentWillUpdate to UNSAFE_componentWillUpdate. The old name is 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 componentWillUpdate to UNSAFE_componentWillUpdate. The old name will no longer work in future versions.
import React from "react";
// Problem: Continuing to use the deprecated componentWillUpdate
class MyComponent extends React.Component {
componentWillUpdate() {
// ...
}
}import React from "react";
// Recommended: Use UNSAFE_componentWillUpdate instead
class MyComponent extends React.Component {
UNSAFE_componentWillUpdate() {
// ...
}
}