react/no-did-update-set-state
eslint-plugin-react
No autofix
eslint.config.js
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/no-did-update-set-state": "error",
},
},
];var Hello = createReactClass({
componentDidUpdate: function() {
this.setState({
name: this.props.name.toUpperCase()
});
},
render: function() {
return <div>Hello {this.state.name}</div>;
}
});var Hello = createReactClass({
componentDidUpdate: function() {
this.props.onUpdate();
},
render: function() {
return <div>Hello {this.props.name}</div>;
}
});var Hello = createReactClass({
componentDidUpdate: function() {
this.onUpdate(function callback(newName) {
this.setState({
name: newName
});
});
},
render: function() {
return <div>Hello {this.props.name}</div>;
}
});Examples from the ESLint documentation.
react/no-did-update-set-state
eslint-plugin-react
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/no-did-update-set-state": "error",
},
},
];react/no-did-update-set-state
react plugin · correctness
{
"plugins": [
"react"
],
"rules": {
"react/no-did-update-set-state": "error"
}
}Biome does not have this rule.
Disallow file extensions that may contain JSX
Disallow creating unstable components inside components
Disallow .bind() or arrow functions in JSX props
Enforce shorthand or standard form for React fragments
Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes