Fix PickerAndroid breaking when child is null. (#23884)

Summary:
On conditional rendering if child is null then the PickerAndroid breaks.

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] - Filter props.children.
Pull Request resolved: https://github.com/facebook/react-native/pull/23884

Differential Revision: D14436860

Pulled By: cpojer

fbshipit-source-id: 6a8fca604acf77c20729f26a53cd7f67e514deac
This commit is contained in:
a-c-sreedhar-reddy
2019-03-13 00:29:59 -07:00
committed by Facebook Github Bot
parent 3898ee3a01
commit 85e8b3e21d

View File

@@ -113,7 +113,9 @@ class PickerAndroid extends React.Component<
if (this.props.onValueChange) {
const position = event.nativeEvent.position;
if (position >= 0) {
const children = React.Children.toArray(this.props.children);
const children = React.Children.toArray(this.props.children).filter(
item => item != null,
);
const value = children[position].props.value;
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was
* found when making Flow check .android.js files. */