DocumentationRulesno-redundant-should-component-update

no-redundant-should-component-update

Rule category

Correctness.

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>;
  }
}