react-native/Libraries/Components/Picker
Atticus White 2e4ab9ff70 Bugfix - Only add valid IOSPicker items.
Summary:
Fixes https://github.com/facebook/react-native/issues/9216.

As nickzuber describes in #9216, conditional `Picker.Item` elements will lead to exceptions downstream when the `Picker` attempts to construct the collection of items.

[In the picker source](a2fb703bbb/Libraries/Components/Picker/PickerIOS.ios.js (L48-L53)) we can see that `child.props` is accessed when `child` has the potential to be an invalid `React` element.

```js
ReactChildren.forEach(props.children, function (child, index) {
  if (child.props.value === props.selectedValue) {
    selectedIndex = index;
  }
  items.push({value: child.props.value, label: child.props.label});
});
```

This change ensures the incoming element is valid

```diff
ReactChildren.forEach(props.children, function (child, index) {
+ if (!React.isValidElement(child)) {
+   return;
+ }
  if (child.props.value === props.selectedValue) {
    selectedIndex = index;
  }
  items.
Closes https://github.com/facebook/react-native/pull/9243

Differential Revision: D3847514

Pulled By: spicyj

fbshipit-source-id: f46fbd4b0f81de7a92e1ca3e60b5ed15a9cbbf78
2016-09-10 21:43:37 -07:00
..
Picker.js Convert from React.createClass to ES6 classes 2016-07-26 01:13:31 -07:00
PickerAndroid.android.js Brings accessibilityLabel into PickerAndroid 2016-09-07 16:58:30 -07:00
PickerAndroid.ios.js Add a cross-platform Picker 2016-01-29 03:59:54 -08:00
PickerIOS.android.js Removed exported constants for fixed-size views 2016-04-26 04:21:39 -07:00
PickerIOS.ios.js Bugfix - Only add valid IOSPicker items. 2016-09-10 21:43:37 -07:00