From 5d52da130c46ee592084f1984d81385b4128e98f Mon Sep 17 00:00:00 2001 From: Aahmad Date: Sun, 1 Dec 2024 05:11:16 +0500 Subject: [PATCH] Fix: Prevent 'TypeError: Cannot read property 'value' of undefined' in Picker component --- js/PickerAndroid.android.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/PickerAndroid.android.js b/js/PickerAndroid.android.js index 0ef107e35..166057727 100644 --- a/js/PickerAndroid.android.js +++ b/js/PickerAndroid.android.js @@ -111,7 +111,7 @@ function PickerAndroid(props: PickerAndroidProps, ref: PickerRef): React.Node { if (child === null) { return null; } - if (child.props.value === props.selectedValue) { + if (child?.props?.value === props.selectedValue) { jsValue = index; } }); @@ -159,13 +159,13 @@ function PickerAndroid(props: PickerAndroidProps, ref: PickerRef): React.Node { if (child === null) { return null; } - if (child.props.value === props.selectedValue) { + if (child?.props?.value === props.selectedValue) { selected = index; } - const {enabled = true} = child.props; + const {enabled = true} = child.props || {}; - const {color, contentDescription, label, style = {}} = child.props; + const {color, contentDescription, label, style = {}} = child.props || {}; const processedColor = processColor(color);