picker icon indicating copy to clipboard operation
picker copied to clipboard

`onValueChange` type for the web picker is wrong

Open trevorzablocki2 opened this issue 2 years ago • 2 comments

The type for the onValueChange prop of the web picker is set to the following (here):

  onValueChange?: (number | string, number) => void,

but the value coming back from the event for the option components are always strings. It seems like these returned values should be parsed to the correct type based on the passed in option values or this type should just indicate it will only be a string.

trevorzablocki2 avatar Dec 14 '22 19:12 trevorzablocki2

I'm also having the same issue. I got this regression after upgrading to version 2.6.1 (I was previously on version 2.4.10). iOS only. Android still works as expected.

Reproducible snippet:

<Picker onValueChange={value => console.log('changed', value, typeof value)}>
  <Picker.Item label='One' value={1}/> // outputs -> changed "1" string
  <Picker.Item label='Two' value={2}/> // outputs -> changed "2" string
</Picker>

almirfilho avatar Mar 21 '24 22:03 almirfilho

Getting this issue as well. It might need a tiny change in https://github.com/react-native-picker/picker/blob/7b7a95f4fe842d0a0c696310f9f10a8267247227/js/Picker.web.js#L59 somehow by checking initials values send using Picker.Item

MoOx avatar Apr 11 '24 13:04 MoOx