1.2.0 • Published 8 years ago

preact-shallow-compare v1.2.0

Weekly downloads
191
License
MIT
Repository
github
Last release
8 years ago

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);
    }

}