Remove the shouldComponentUpdate
method from PureComponent
. PureComponent
already has an implementation.
PureComponent
provides an implementation for shouldComponentUpdate
which compares props by reference to determine if they have changed.
Apply with the Grit CLI
grit apply remove_should_component_update_from_pure_components
Removes the entire shouldComponentUpdate() when extending React.PureComponent
BEFORE
class Foo extends React.PureComponent { customMethod() {} shouldComponentUpdate() {} render() { return <Hello />; } }
AFTER
class Foo extends React.PureComponent { customMethod() {} render() { return <Hello />; } }
Removes the entire shouldComponentUpdate() when extending destructured PureComponent
BEFORE
class Foo extends PureComponent { customMethod() {} shouldComponentUpdate() {} render() { return <Hello />; } }
AFTER
class Foo extends PureComponent { customMethod() {} render() { return <Hello />; } }
Does nothing when extending React.Component
JAVASCRIPT
class Foo extends React.Component { customMethod() {} shouldComponentUpdate() {} render() { return <Hello />; } }