/shallow

exposes some preact internals

Primary LanguageJavaScript

Shallow

Modified version of shallow-compare. I got tired of having to hack access to the Diff code. Exposes Compare and Diff equally.

Example

// preact
import {Component, h}		from 'preact';
import shallow			from 'shallow';

class Foo extends Component {
  constructor( props ) {
    super(props);
    this.state = {'color': 'blue'};
  }

  shouldComponentUpdate( nextProps, nextState ) {
    return shallow.Compare(this, nextProps, nextState);
  }

  render( props, state ) {
    return <div>{state.color}</div>;
  }
}