no-redundant-should-component-update
Full Name in eslint-plugin-react-x
react-x/no-redundant-should-component-updateFull Name in @eslint-react/eslint-plugin
@eslint-react/no-redundant-should-component-updateFeatures
🔍
Presets
corerecommendedrecommended-typescriptrecommended-type-checked
What it does
Prevents usage of shouldComponentUpdate when extending React.PureComponent.
Why is this bad?
While having shouldComponentUpdate will still work, it becomes pointless to extend React.PureComponent.
Examples
Failing
import React from "react";
class Example extends React.PureComponent {
// 'Example' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'.
shouldComponentUpdate() {
// do check
return true;
}
render() {
return <div>Radical!</div>;
}
}Passing
import React from "react";
class Example extends React.Component {
shouldComponentUpdate() {
// do check
return true;
}
render() {
return <div>Radical!</div>;
}
}