# all files / src/ PureComponent.js

50% Statements 4/8
0% Branches 0/2
0% Functions 0/2
50% Lines 4/8

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24

    1×

    1×

    1×

    1×import {
        Component
    } from './Component'
    import {
        inherit
    } from './util'
    import {
        shallowEqual
    } from './shallowEqual'

    export function PureComponent(props, context) {
        Component.call(this, props,context)
    }

    inherit(PureComponent, Component)

    let fn = PureComponent.prototype

    fn.shouldComponentUpdate = function shallowCompare(nextProps, nextState) {
        var a = shallowEqual(this.props, nextProps)
        var b = shallowEqual(this.state, nextState)
        return !a || !b
    }
    fn.isPureComponent = true