no-component-will-mount
Full Name in eslint-plugin-react-x
react-x/no-component-will-mount
Full Name in @eslint-react/eslint-plugin
@eslint-react/no-component-will-mount
Features
🔍
🔄
Presets
core
recommended
recommended-typescript
recommended-type-checked
What it does
Prevents usage of componentWillMount
in class components.
This API has been 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.
A safe codemod is available for this rule.
Examples
Failing
import React from "react";
interface MyComponentProps {
name: string;
}
class MyComponent extends React.Component<MyComponentProps> {
componentWillMount() {
// ...
}
}
Passing
import React from "react";
interface MyComponentProps {
name: string;
}
class MyComponent extends React.Component<MyComponentProps> {
UNSAFE_componentWillMount() {
// ...
}
}