fix: React.memo resolvers not accounting for all props (#6042)

This commit is contained in:
David Luzar 2023-01-09 10:24:17 +01:00 committed by GitHub
parent 06b45e0cfc
commit 618442299f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 27 deletions

View file

@ -709,3 +709,15 @@ export const ReactChildrenToObject = <
return acc;
}, {} as Partial<T>);
};
export const isShallowEqual = <T extends Record<string, any>>(
objA: T,
objB: T,
) => {
const aKeys = Object.keys(objA);
const bKeys = Object.keys(objA);
if (aKeys.length !== bKeys.length) {
return false;
}
return aKeys.every((key) => objA[key] === objB[key]);
};