Skip to content

Commit

Permalink
added a fix for picker crashing when multipe is enabled and an item i…
Browse files Browse the repository at this point in the history
…s selected
  • Loading branch information
medmo7 committed May 31, 2022
1 parent a6b2e7f commit 3ce3904
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit 3ce3904

Please sign in to comment.