react-doctor/no-redundant-should-component-update
Drop shouldComponentUpdate when extending PureComponent, or extend React.Component if custom comparison logic is genuinely needed.
- Category: Architecture
- Severity: warn
- Source:
oxlint-plugin-react-doctor - Framework: global
- Enabled when: always
- Documentation: https://oxc.rs/docs/guide/usage/linter/rules/react/no-redundant-should-component-update
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Fires when a class extends PureComponent (a bare identifier named PureComponent or the React.PureComponent member expression — strictly object.name === "React" and property PureComponent) AND its body defines a shouldComponentUpdate member, as a method, an arrow class field, or a string-literal key, since PureComponent already implements a shallow prop/state comparison that makes the override redundant. The check is purely structural: it matches the superclass name and the member name, never the method body, and it does not handle a string-literal-keyed or computed superClass. False positive: a class extending a non-React class that happens to be named PureComponent will be flagged, since the match is name-only regardless of import origin. Conversely it misses (false negative) an aliased React import — e.g. extends RPC where RPC aliases React.PureComponent — because the superclass identifier isn't literally PureComponent, so nothing fires.
Fix prompt
Use this once validation confirms the diagnostic is real.
Delete the redundant shouldComponentUpdate and rely on PureComponent's built-in shallow comparison: class Foo extends React.PureComponent { render() { /* ... */ } }. If you truly need custom update logic (deep comparison, ignoring a field), switch the base class to React.Component instead so the method is meaningful: class Foo extends React.Component { shouldComponentUpdate(next) { /* custom */ } }. Don't keep both — PureComponent plus an override defeats the optimization it provides. See https://oxc.rs/docs/guide/usage/linter/rules/react/no-redundant-should-component-update
Related rules
More Architecture rules from the rules reference:
react-doctor/no-render-in-render: Extract to a named component: `const ListItem = ({ item }) => <div>{item.name}</div>`react-doctor/no-render-prop-children: Replace `renderXxx` props with compound subcomponents (e.g. `<Modal.Header>`) or `children` so the parent doesn't dictate every customization pointreact-doctor/no-set-state: Lift state up or use an external store instead of this.setState.react-doctor/no-side-tab-border: Use a subtler accent (box-shadow inset, background gradient, or border-bottom) instead of a thick one-sided borderreact-doctor/no-unescaped-entities: Replace bare ' / " / > / } characters in JSX text with HTML entities.