Skip to content

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

@GregoryPotdevin

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.

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