1 | import { Component } from 'preact';
|
2 | import { shallowDiffers } from './util';
|
3 |
|
4 | /**
|
5 | * Component class with a predefined `shouldComponentUpdate` implementation
|
6 | */
|
7 | export function PureComponent(p) {
|
8 | this.props = p;
|
9 | }
|
10 | PureComponent.prototype = new Component();
|
11 | // Some third-party libraries check if this property is present
|
12 | PureComponent.prototype.isPureReactComponent = true;
|
13 | PureComponent.prototype.shouldComponentUpdate = function(props, state) {
|
14 | return shallowDiffers(this.props, props) || shallowDiffers(this.state, state);
|
15 | };
|