mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-06 22:37:14 +08:00
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:
committed by
Facebook Github Bot
parent
8721ef0916
commit
cd18527e77
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user