Skip to content

Instantly share code, notes, and snippets.

/**
* A "pure" component means that the render function only depends on props and state,
* which allows us to add performance optimizations (see `shouldComponentUpdate` below).
*/
class PureComponent<P, S> extends React.Component<P, S> {
shouldComponentUpdate(nextProps: P, nextState: S): boolean {
return !shallowEqual(this.props, nextProps) ||
!shallowEqual(this.state, nextState);
}
}