-
Notifications
You must be signed in to change notification settings - Fork 49.5k
Description
We were previously using the shallowEqual
method from the react/lib implementation, which was used in the following way:
shouldComponentUpdate(nextProps, nextState) {
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
}
When updating to 0.14, we migrated to using the npm package for 'react-addons-shallow-compare'.
We assumed shallowCompare worked the same way, but anything we passed to shallowCompare was returning true
shouldComponentUpdate(nextProps, nextState) {
return !shallowCompare(this.props, nextProps) || !shallowCompare(this.state, nextState);
}
After doing some low level testing, even the following was returning true:
shallowCompare({value: true}, {value: false});
Using the Chrome dev tools I was able to discover the method signature that was expected:
I think we need to better document this method somewhere, either in the npm package page (https://www.npmjs.com/package/react-addons-shallow-compare) or on the addons page (https://facebook.github.io/react/docs/addons.html) to help out others wanting to make this transition.