picker icon indicating copy to clipboard operation
picker copied to clipboard

Picker 2.6+ transforms numeric values to strings

Open swrobel opened this issue 1 year ago • 4 comments

If I have a Picker Item with value={10}, using 2.5.1, the value will be set to 10 when I select that, but starting with 2.6.0, it will be set to "10" which is a substantial breaking change.

swrobel avatar Dec 27 '23 02:12 swrobel

Experiencing the same issue with 2.6.1 on iOS (Android works as expected). Reverting to 2.5.1 for now, which appears compatible with Expo 50 so far (for the Expo users out there).

stevenpal avatar Feb 01 '24 20:02 stevenpal

We are having the same issue in our project, we'll need to revert until a fix is released

elkinjosetm avatar Feb 08 '24 16:02 elkinjosetm

@WoLewicki since you worked on the PR that seems to have introduced this bug, could you take a look at this?

swrobel avatar Mar 26 '24 22:03 swrobel

Yeah, I can see that, as mentioned here: https://github.com/react-native-picker/picker/pull/456/files/624af21c3f1fa6212d5f13dfb7f21de8e43ba3af#r1526543524, this makes the value always a string. It's like this due to codegen not accepting mixed types :disappointed: We would need to change this type to UnsafeMixed and parse it correctly on the native side. It is doable, but right now I have little time to do it unfortunately. I took the same approach here: https://github.com/software-mansion/react-native-svg/pull/2238 if someone is willing to contribute. If not, I'll try to find an hour to do it.

WoLewicki avatar Mar 28 '24 15:03 WoLewicki