Documentation Issues with react-addons-shallow-compare Package
See original GitHub issueWe 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.
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (4 by maintainers)
For sure. Where would I start doing that?
Thanks, yes it should. I’m following up now and fixing the link in the readme so npm links to the right thing.