UNPKG

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