You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
446 B
20 lines
446 B
function hasDifferentItems(prevItems, currentItems, idProp = 'id') {
|
|
if (prevItems === currentItems) {
|
|
return false;
|
|
}
|
|
|
|
if (prevItems.length !== currentItems.length) {
|
|
return true;
|
|
}
|
|
|
|
const currentItemIds = new Set();
|
|
|
|
currentItems.forEach((currentItem) => {
|
|
currentItemIds.add(currentItem[idProp]);
|
|
});
|
|
|
|
return prevItems.every((prevItem) => currentItemIds.has(prevItem[idProp]));
|
|
}
|
|
|
|
export default hasDifferentItems;
|