npm.io
1.2.0 • Published 9 years ago

preact-shallow-compare

Licence
MIT
Version
1.2.0
Deps
0
Vulns
0
Weekly
0
Stars
6
DeprecatedThis package is deprecated

preact-shallow-compare

npm package

shallowCompare for preact. react-shallow-compare detached from React.

##Example

import { h, Component } from 'preact';
import shallowCompare from 'preact-shallow-compare';


class Foo extends Component {

    constructor(props) {

        super(props);

        this.state = { color: 'blue' };
    }

    shouldComponentUpdate(nextProps, nextState) {

        return shallowCompare(this, nextProps, nextState);
    }

    render() {

        return h('div', null, this.state.color);
    }

}

Keywords