From 85e8b3e21d9399027d07252544ef5a8ed01ff8f7 Mon Sep 17 00:00:00 2001 From: a-c-sreedhar-reddy Date: Wed, 13 Mar 2019 00:29:59 -0700 Subject: [PATCH] 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 && } ``` [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 --- Libraries/Components/Picker/PickerAndroid.android.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/Picker/PickerAndroid.android.js b/Libraries/Components/Picker/PickerAndroid.android.js index 375e6e8f94f352..9dcc8cc10b7ca6 100644 --- a/Libraries/Components/Picker/PickerAndroid.android.js +++ b/Libraries/Components/Picker/PickerAndroid.android.js @@ -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. */