From 3ce3904306e6901dc3c74077d23da5bd39b110fc Mon Sep 17 00:00:00 2001 From: mohamed Date: Tue, 31 May 2022 12:07:27 +0100 Subject: [PATCH] added a fix for picker crashing when multipe is enabled and an item is selected --- src/components/Picker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Picker.js b/src/components/Picker.js index 9bbacc7..6e79f9a 100644 --- a/src/components/Picker.js +++ b/src/components/Picker.js @@ -1263,7 +1263,7 @@ function Picker({ // Not a reliable method for external value changes. if (multiple) { - if (memoryRef.current.value.includes(item[_schema.value])) { + if (memoryRef.current.value?.includes(item[_schema.value])) { const index = memoryRef.current.items.findIndex(x => x[_schema.value] === item[_schema.value]); if (index > -1) { @@ -1279,7 +1279,7 @@ function Picker({ setValue(state => { if (multiple) { - let _state = state !== null ? [...state] : []; + let _state = state !== null && state !== undefined ? [...state] : []; if (_state.includes(item[_schema.value])) { // Remove the value