Skip to content

Commit 1195a8f

Browse files
ShiHuifacebook-github-bot
ShiHui
authored andcommitted
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
1 parent 6dab5dc commit 1195a8f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

React/Views/RCTPicker.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ - (void)pickerView:(__unused UIPickerView *)pickerView
9898
didSelectRow:(NSInteger)row inComponent:(__unused NSInteger)component
9999
{
100100
_selectedIndex = row;
101-
if (_onChange) {
101+
if (_onChange && _items.count > row) {
102102
_onChange(@{
103103
@"newIndex": @(row),
104104
@"newValue": RCTNullIfNil(_items[row][@"value"]),

0 commit comments

Comments
 (0)