Fix RCTPicker crash

Summary:
If user slide picker when picker item is zero, `UIPickerViewDelegate` will call `pickerView:didSelectRow:inComponent` row=0, `_items[row][@"value"]` will crash.
Closes https://github.com/facebook/react-native/pull/12187

Differential Revision: D4709882

Pulled By: mkonicek

fbshipit-source-id: 772c819d4eaef41ac983287877bda2918f40b1a7
This commit is contained in:
ShiHui 2017-03-14 17:45:39 -07:00 committed by Facebook Github Bot
parent 6dab5dcd7c
commit 1195a8f3e6
1 changed files with 1 additions and 1 deletions

View File

@ -98,7 +98,7 @@ numberOfRowsInComponent:(__unused NSInteger)component
didSelectRow:(NSInteger)row inComponent:(__unused NSInteger)component
{
_selectedIndex = row;
if (_onChange) {
if (_onChange && _items.count > row) {
_onChange(@{
@"newIndex": @(row),
@"newValue": RCTNullIfNil(_items[row][@"value"]),