TelegramPWA/src/util/arePropsShallowEqual.ts
Alexander Zinchuk 3afcde3217 Initial commit
2021-04-09 14:11:51 +03:00

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]);
}