From 29ed8d2e0286dfb15e54e2511578f242eb3507d2 Mon Sep 17 00:00:00 2001 From: Raghupathi Reddy Date: Wed, 5 Sep 2018 10:50:29 -0400 Subject: [PATCH] Condition check added to avoid empty object spread --- lib/react-native-multi-select.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/react-native-multi-select.js b/lib/react-native-multi-select.js index 6295db5..a82a896 100644 --- a/lib/react-native-multi-select.js +++ b/lib/react-native-multi-select.js @@ -283,7 +283,9 @@ export default class MultiSelect extends Component { singleItem => item[uniqueKey] === singleItem, ); } else { - newItems = [...selectedItems, item[uniqueKey]]; + if (selectedItems === undefined || selectedItems.length == 0) + newItems = [item[uniqueKey]]; + else newItems = [...selectedItems, item[uniqueKey]]; } // broadcast new selected items state to parent component onSelectedItemsChange(newItems);