question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation Issues with react-addons-shallow-compare Package

See original GitHub issue

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:

image

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:closed
  • Created 8 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
zramaekerscommented, Nov 4, 2015

For sure. Where would I start doing that?

0reactions
zpaocommented, Aug 29, 2016

Thanks, yes it should. I’m following up now and fixing the link in the readme so npm links to the right thing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Shallow Compare - React
shallowCompare returns true if the shallow comparison for props or state fails and therefore the component should update. shallowCompare returns false if the ......
Read more >
react-addons-shallow-compare | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >
дэн on Twitter: "Be careful with react-addons-shallow-compare, its ...
Documentation Issues with react-addons-shallow-compare Package · Issue #5378 ... We were previously using the shallowEqual method from the react/lib ...
Read more >
How to use the react-addons-shallow-compare function ... - Snyk
To help you get started, we've selected a few react-addons-shallow-compare examples, based on popular ways it is used in public projects.
Read more >
react-addons-shallow-compare - npm
react -addons-shallow-compare. 15.6.3 • Public • Published 2 years ago. Readme · Code Beta · 1 Dependency · 737 Dependents · 62 Versions ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found