Skip to content

Commit

Permalink
Fix breaking of PickerAndroid when child is null. (#23748)
Browse files Browse the repository at this point in the history
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: #23748

Differential Revision: D14319140

Pulled By: cpojer

fbshipit-source-id: 07d48cd054a131e6984cfe3bdce7538ffbc50622
  • Loading branch information
a-c-sreedhar-reddy authored and facebook-github-bot committed Mar 5, 2019
1 parent 8721ef0 commit cd18527
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Libraries/Components/Picker/PickerAndroid.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit cd18527

Please sign in to comment.