@@ -6,7 +6,7 @@ export const init = ({ propsOptions, optionsTransformer }) => ({
6
6
...( optionsTransformer && { originalOptions : propsOptions } ) ,
7
7
} ) ;
8
8
9
- const reducer = ( state , { type, payload, options = [ ] , optionsTransformer } ) => {
9
+ const reducer = ( state , { type, payload, options = [ ] , optionsTransformer, compareValues } ) => {
10
10
switch ( type ) {
11
11
case 'updateOptions' :
12
12
return {
@@ -42,14 +42,11 @@ const reducer = (state, { type, payload, options = [], optionsTransformer }) =>
42
42
options : optionsTransformer
43
43
? optionsTransformer ( [
44
44
...state . options ,
45
- ...options . filter ( ( { value } ) => ! state . options . find ( ( option ) => payload . compareValues ( option . value , value ) ) ) ,
45
+ ...options . filter ( ( { value } ) => ! state . options . find ( ( option ) => compareValues ( option . value , value ) ) ) ,
46
46
] )
47
- : [ ...state . options , ...options . filter ( ( { value } ) => ! state . options . find ( ( option ) => payload . compareValues ( option . value , value ) ) ) ] ,
47
+ : [ ...state . options , ...options . filter ( ( { value } ) => ! state . options . find ( ( option ) => compareValues ( option . value , value ) ) ) ] ,
48
48
...( optionsTransformer && {
49
- originalOptions : [
50
- ...state . options ,
51
- ...options . filter ( ( { value } ) => ! state . options . find ( ( option ) => payload . compareValues ( option . value , value ) ) ) ,
52
- ] ,
49
+ originalOptions : [ ...state . options , ...options . filter ( ( { value } ) => ! state . options . find ( ( option ) => compareValues ( option . value , value ) ) ) ] ,
53
50
} ) ,
54
51
} ;
55
52
default :
0 commit comments