picker
picker copied to clipboard
`onValueChange` type for the web picker is wrong
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.
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>
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