Skip to content

Latest commit

 

History

History
66 lines (52 loc) · 1.22 KB

no-redundant-should-component-update.md

File metadata and controls

66 lines (52 loc) · 1.22 KB

Disallow usage of shouldComponentUpdate when extending Inferno.PureComponent (inferno/no-redundant-should-component-update)

Warns if you have shouldComponentUpdate defined when defining a component that extends Inferno.PureComponent. While having shouldComponentUpdate will still work, it becomes pointless to extend PureComponent.

Rule Details

Examples of incorrect code for this rule:

class Foo extends Inferno.PureComponent {
  shouldComponentUpdate() {
    // do check
  }

  render() {
    return <div>Radical!</div>
  }
}

function Bar() {
  return class Baz extends Inferno.PureComponent {
    shouldComponentUpdate() {
      // do check
    }

    render() {
      return <div>Groovy!</div>
    }
  }
}

Examples of correct code for this rule:

class Foo extends Inferno.Component {
  shouldComponentUpdate() {
    // do check
  }

  render() {
    return <div>Radical!</div>
  }
}

function Bar() {
  return class Baz extends Inferno.Component {
    shouldComponentUpdate() {
      // do check
    }

    render() {
      return <div>Groovy!</div>
    }
  }
}

class Qux extends Inferno.PureComponent {
  render() {
    return <div>Tubular!</div>
  }
}