Skip to content

Bug: shallowCompare doesn't work if the objects have different keys #2

Description

@GregoryPotdevin

The current shallowCompare implementation doesn't work if the objects have different keys

You can try shallowCompare with the following code :

console.log(shallowCompare({ a: 1, b: 1 }, { a: 1 }));
console.log(shallowCompare({ a: 1 }, { a: 1, b: 1 }));

shallowCompare({ a: 1, b: 1 }, { a: 1 }) => true

This is because we only iterate on the keys of nextProps, ignoring any extra props in prevProps.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions