From 8edbfea13f9edc79aff10ff2ae996c190ae0e724 Mon Sep 17 00:00:00 2001 From: Hayden Linder <57159583+haydenlinder@users.noreply.github.com> Date: Thu, 21 Mar 2024 01:42:06 -0700 Subject: [PATCH] Update reducer.js --- packages/common/src/use-select/reducer.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/common/src/use-select/reducer.js b/packages/common/src/use-select/reducer.js index 688fcd51d..bf5e5ed70 100644 --- a/packages/common/src/use-select/reducer.js +++ b/packages/common/src/use-select/reducer.js @@ -32,7 +32,10 @@ const reducer = (state, { type, payload, options = [], optionsTransformer }) => ...state, isInitialLoaded: true, }; - case 'setPromises': + case 'setPromises': { + const compareValues = payload.compareValues; + delete payload.compareValues; + return { ...state, promises: { @@ -42,16 +45,15 @@ const reducer = (state, { type, payload, options = [], optionsTransformer }) => options: optionsTransformer ? optionsTransformer([ ...state.options, - ...options.filter(({ value }) => !state.options.find((option) => payload.compareValues(option.value, value))), + ...options.filter(({ value }) => !state.options.find((option) => compareValues(option.value, value))), ]) - : [...state.options, ...options.filter(({ value }) => !state.options.find((option) => payload.compareValues(option.value, value)))], + : [...state.options, ...options.filter(({ value }) => !state.options.find((option) => compareValues(option.value, value)))], ...(optionsTransformer && { - originalOptions: [ - ...state.options, - ...options.filter(({ value }) => !state.options.find((option) => payload.compareValues(option.value, value))), - ], + originalOptions: [...state.options, ...options.filter(({ value }) => !state.options.find((option) => compareValues(option.value, value)))], }), }; + } + default: return state; }