DocumentationRulesno-redundant-should-component-update

no-redundant-should-component-update

Full Name in eslint-plugin-react-x

react-x/no-redundant-should-component-update

Full Name in @eslint-react/eslint-plugin

@eslint-react/no-redundant-should-component-update

Features

🔍

Presets

  • core
  • recommended
  • recommended-typescript
  • recommended-type-checked

What it does

Prevents usage of shouldComponentUpdate when extending React.PureComponent.

While having shouldComponentUpdate will still work, it becomes pointless to extend React.PureComponent.

Examples

Failing

import React from "react";
 
class MyComponent 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 MyComponent extends React.Component {
  shouldComponentUpdate() {
    // do check
    return true;
  }
 
  render() {
    return <div>Radical!</div>;
  }
}

Implementation