12 lines
394 B
TypeScript
12 lines
394 B
TypeScript
export default function arePropsShallowEqual(currentProps: AnyLiteral, newProps: AnyLiteral) {
|
|
const currentKeys = Object.keys(currentProps);
|
|
const currentKeysLength = currentKeys.length;
|
|
const newKeysLength = Object.keys(newProps).length;
|
|
|
|
if (currentKeysLength !== newKeysLength) {
|
|
return false;
|
|
}
|
|
|
|
return currentKeys.every((prop) => currentProps[prop] === newProps[prop]);
|
|
}
|