Skip to content

Commit

Permalink
Fix: Prevent 'TypeError: Cannot read property 'value' of undefined' i…
Browse files Browse the repository at this point in the history
…n Picker component
  • Loading branch information
aahmadsaleem95 committed Dec 1, 2024
1 parent b16276c commit 5d52da1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions js/PickerAndroid.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 5d52da1

Please sign in to comment.