Fix breaking of PickerAndroid when child is null. (#23748)

Summary:
when conditional rendering is used then picker breaks when the child is null.

This conditional rendering inside Picker fails when a is 1, because child will be null in PickerAndroid.android.js.
```
{
   this.state.a === 2 && <Picker.Item label="value" value="value" />
}
```

[ANDROID] [FIXED] - When child is null it returns.
Pull Request resolved: https://github.com/facebook/react-native/pull/23748

Differential Revision: D14319140

Pulled By: cpojer

fbshipit-source-id: 07d48cd054a131e6984cfe3bdce7538ffbc50622
This commit is contained in:
A C SREEDHAR REDDY
2019-03-04 18:40:02 -08:00
committed by Facebook Github Bot
parent 8721ef0916
commit cd18527e77

View File

@@ -64,6 +64,9 @@ class PickerAndroid extends React.Component<
): PickerAndroidState {
let selectedIndex = 0;
const items = React.Children.map(props.children, (child, index) => {
if (child === null) {
return;
}
if (child.props.value === props.selectedValue) {
selectedIndex = index;
}