You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
533 B
16 lines
533 B
|
2 years ago
|
import { Component } from 'preact';
|
||
|
|
import { shallowDiffers } from './util';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Component class with a predefined `shouldComponentUpdate` implementation
|
||
|
|
*/
|
||
|
|
export function PureComponent(p) {
|
||
|
|
this.props = p;
|
||
|
|
}
|
||
|
|
PureComponent.prototype = new Component();
|
||
|
|
// Some third-party libraries check if this property is present
|
||
|
|
PureComponent.prototype.isPureReactComponent = true;
|
||
|
|
PureComponent.prototype.shouldComponentUpdate = function (props, state) {
|
||
|
|
return shallowDiffers(this.props, props) || shallowDiffers(this.state, state);
|
||
|
|
};
|