Changed the order of concating values

This commit is contained in:
Yulia Shanyrova 2022-10-11 16:08:43 +02:00
parent 8afeb5916b
commit aedb6a52d5

View file

@ -61,8 +61,8 @@ const RemoteSelect = inject('store')(
};
function mergeOptions(oldOptions: SelectableValue[], newOptions: SelectableValue[]) {
const existedValues = oldOptions.map((o) => o.value);
return newOptions.filter(({ value }) => !existedValues.includes(value)).concat(oldOptions);
const existingValues = oldOptions.map((o) => o.value);
return oldOptions.concat(newOptions.filter(({ value }) => !existingValues.includes(value)));
}
const [options, setOptions] = useReducer(mergeOptions, []);