UNPKG

preact

Version:

Fast 3kb React-compatible Virtual DOM library.

20 lines (17 loc) 487 B
import { Component } from 'preact'; import { shallowDiffers } from './util'; /** * Component class with a predefined `shouldComponentUpdate` implementation */ export class PureComponent extends Component { constructor(props) { super(props); // Some third-party libraries check if this property is present this.isPureReactComponent = true; } shouldComponentUpdate(props, state) { return ( shallowDiffers(this.props, props) || shallowDiffers(this.state, state) ); } }