Skip to content

Commit

Permalink
Fix RCTPicker crash
Browse files Browse the repository at this point in the history
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 1195a8f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion React/Views/RCTPicker.m
Expand Up @@ -98,7 +98,7 @@ - (void)pickerView:(__unused UIPickerView *)pickerView
didSelectRow:(NSInteger)row inComponent:(__unused NSInteger)component didSelectRow:(NSInteger)row inComponent:(__unused NSInteger)component
{ {
_selectedIndex = row; _selectedIndex = row;
if (_onChange) { if (_onChange && _items.count > row) {
_onChange(@{ _onChange(@{
@"newIndex": @(row), @"newIndex": @(row),
@"newValue": RCTNullIfNil(_items[row][@"value"]), @"newValue": RCTNullIfNil(_items[row][@"value"]),
Expand Down

0 comments on commit 1195a8f

Please sign in to comment.