Plugin: react-featuresRules
no-unsafe
Warn about UNSAFE_ lifecycle methods. This rule is part of eslint-plugin-react-features and provides LLM-optimized error messages.
Keywords: React, UNSAFE, lifecycle, deprecated, ESLint rule, code quality, LLM-optimized
Warn about UNSAFE_ lifecycle methods. This rule is part of eslint-plugin-react-features and provides LLM-optimized error messages.
Quick Summary
| Aspect | Details |
|---|---|
| Severity | Warning (code quality) |
| Auto-Fix | ❌ No auto-fix |
| Category | React |
| ESLint MCP | ✅ Optimized for ESLint MCP integration |
| Best For | All React/JSX projects |
Rule Details
UNSAFE_ lifecycle methods may cause issues with async rendering and will be removed in future React versions.
Examples
❌ Incorrect
class MyComponent extends React.Component {
UNSAFE_componentWillMount() {
this.loadData();
}
UNSAFE_componentWillReceiveProps(nextProps) {
this.updateState(nextProps);
}
UNSAFE_componentWillUpdate(nextProps, nextState) {
this.prepareUpdate();
}
}✅ Correct
class MyComponent extends React.Component {
componentDidMount() {
this.loadData();
}
static getDerivedStateFromProps(props, state) {
return { derivedValue: props.value };
}
getSnapshotBeforeUpdate(prevProps, prevState) {
return this.divRef.scrollHeight;
}
}Related Rules
no-deprecated- Warn about deprecated APIs