shallow-compare
Stand alone shallowCompare for use in libraries that support shouldComponentUpdate
Last updated 7 years ago by tkh44 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install shallow-compare 
SYNC missed versions from official npm registry.

shallow-compare

npm version

Stand alone shallowCompare for use in libraries that support shouldComponentUpdate

API

shallowCompare(instance, nextProps, nextState)

  • instance (component instance) - the component's instance (this)
  • nextProps (object) - the next props
  • nextState (object) - the next state

Example

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

  shouldComponentUpdate (nextProps, nextState) {
    return shallowCompare(this, nextProps, nextState)
  }

  render () {
    return (
      <div>{this.state.color}</div>
    )
  }
}

Current Tags

  • 1.2.2                                ...           latest (7 years ago)

3 Versions

  • 1.2.2                                ...           7 years ago
  • 1.2.1                                ...           8 years ago
  • 1.2.0                                ...           8 years ago
Maintainers (1)
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (4)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE