$ npm install shallow-compare
Stand alone shallowCompare for use in libraries that support shouldComponentUpdate
shallowCompare(instance, nextProps, nextState)
this
)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>
)
}
}
© 2010 - cnpmjs.org x YWFE | Home | YWFE