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:
parent
6dab5dcd7c
commit
1195a8f3e6
|
@ -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"]),
|
||||
|
|
Loading…
Reference in New Issue