Rules
no-component-will-mount
Replaces usage of `componentWillMount` with `UNSAFE_componentWillMount`.
Full Name in eslint-plugin-react-x
react-x/no-component-will-mountFull Name in @eslint-react/eslint-plugin
@eslint-react/no-component-will-mountFeatures
🔄
Presets
x
recommended
recommended-typescript
recommended-type-checked
strict
strict-typescript
strict-type-checked
Rule Details
This API was renamed from componentWillMount to UNSAFE_componentWillMount. The old name has been deprecated. In a future major version of React, only the new name will work.
Common Violations
Invalid
import React from "react";
interface MyComponentProps {
name: string;
}
class MyComponent extends React.Component<MyComponentProps> {
componentWillMount() {
// ...
}
}Valid
import React from "react";
interface MyComponentProps {
name: string;
}
class MyComponent extends React.Component<MyComponentProps> {
UNSAFE_componentWillMount() {
// ...
}
}