Permalink
Browse files

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 #12187

Differential Revision: D4709882

Pulled By: mkonicek

fbshipit-source-id: 772c819d4eaef41ac983287877bda2918f40b1a7
  • Loading branch information...
ShiHui authored and facebook-github-bot committed Mar 15, 2017
1 parent 6dab5dc commit 1195a8f3e6d4a2c46d7d937547a4f95b5c4da79f
Showing with 1 addition and 1 deletion.
  1. +1 −1 React/Views/RCTPicker.m
View
@@ -98,7 +98,7 @@ - (void)pickerView:(__unused UIPickerView *)pickerView
didSelectRow:(NSInteger)row inComponent:(__unused NSInteger)component
{
_selectedIndex = row;
if (_onChange) {
if (_onChange && _items.count > row) {
_onChange(@{
@"newIndex": @(row),
@"newValue": RCTNullIfNil(_items[row][@"value"]),

0 comments on commit 1195a8f

Please sign in to comment.