Skip to content

Documentation Issues with react-addons-shallow-compare Package #5378

@zramaekers

Description

@zramaekers

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions