diff --git a/src/useUpsert.ts b/src/useUpsert.ts index 29387226e6..df6fbd9369 100644 --- a/src/useUpsert.ts +++ b/src/useUpsert.ts @@ -5,17 +5,17 @@ export interface Actions extends ListActions { } const useUpsert = ( - itemsAreTheSame: (upsertedItem: T, existingItem: T) => boolean, + comparisonFunction: (upsertedItem: T, existingItem: T) => boolean, initialList: T[] = [] ): [T[], Actions] => { const [items, actions] = useList(initialList); const upsert = (upsertedItem: T) => { - const itemAlreadyExists = items.find(item => itemsAreTheSame(upsertedItem, item)); + const itemAlreadyExists = items.find(item => comparisonFunction(upsertedItem, item)); if (itemAlreadyExists) { return actions.set( items.map(existingItem => { - if (itemsAreTheSame(upsertedItem, existingItem)) { + if (comparisonFunction(upsertedItem, existingItem)) { return upsertedItem; } return existingItem;