Rules
no-redundant-should-component-update
Disallows 'shouldComponentUpdate' when extending 'React.PureComponent'.
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-updatePresets
x
recommended
recommended-typescript
recommended-type-checked
strict
strict-typescript
strict-type-checked
Rule Details
While having shouldComponentUpdate still works, it becomes pointless to extend React.PureComponent.
Common Violations
Invalid
import React from "react";
class MyComponent extends React.PureComponent {
// 'Example' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'.
shouldComponentUpdate() {
// perform check
return true;
}
render() {
return <div>Radical!</div>;
}
}Valid
import React from "react";
class MyComponent extends React.Component {
shouldComponentUpdate() {
// perform check
return true;
}
render() {
return <div>Radical!</div>;
}
}Resources
See Also
react-x/no-class-component
Disallows class components except for error boundaries.react-x/no-component-will-mount
Replaces usage ofcomponentWillMountwithUNSAFE_componentWillMount.react-x/no-component-will-receive-props
Replaces usage ofcomponentWillReceivePropswithUNSAFE_componentWillReceiveProps.react-x/no-component-will-update
Replaces usage ofcomponentWillUpdatewithUNSAFE_componentWillUpdate.