quidone / react-native-wheel-picker

Wheel Picker for React Native
MIT License
52 stars 10 forks source link

"key" prop spread into JSX warning when using keyExtractor #11

Closed bobbyziom closed 3 weeks ago

bobbyziom commented 1 month ago

When adding keyExtrator like so:

<WheelPicker
    keyExtractor={(item) => item.key}
    data={orgTypes}
    onValueChanged={({ item: { value } }) => onOrgTypeChange(value)}
    overlayItemStyle={{ backgroundColor: palette.success[100] }}
    style={{ flexGrow: 1 }}
    itemTextStyle={{ color: palette.primary[200], fontSize: 18, fontWeight: 'bold' }}
  />

produces warning:

Warning: A props object containing a "key" prop is being spread into JSX:
  let props = {key: someKey, item: ..., index: ..., faces: ..., renderItem: ..., itemTextStyle: ...};
  <PickerItemContainer {...props} />
React keys must be passed directly to JSX without using spread:
  let props = {item: ..., index: ..., faces: ..., renderItem: ..., itemTextStyle: ...};
  <PickerItemContainer key={someKey} {...props} />
rozhkovs commented 1 month ago

Thanks for the issue!

Feel free to open a PR, small changes are required there.)

anthonychemaly commented 3 weeks ago

Kindly review: https://github.com/quidone/react-native-wheel-picker/pull/12

rozhkovs commented 2 weeks ago

@anthonychemaly @bobbyziom Released in 1.1.0!

bobbyziom commented 2 weeks ago

@rozhkovs fantastic, thank you!