Open milennaj opened 3 years ago
@milennaj same problem ! i could fix it by remove key prop on RNPickerSelect component
Removing the key is not a solution since then we will get a warning: Cannot update component inside function and issue: https://github.com/lawnstarter/react-native-picker-select/issues/346
@milennaj
I got this warning when I tried to set a value that is not available in the items list
@ArianHamdi yes, that was the problem. Initially in the code we were setting the value to the object that isn't in the list. Thank you.
Hi I have the same issue, and removing the key prop doesn't solve it in my case since from the begining it wasn't set. 😞
This issue is still present on version 8.0.3. If you have the key prop on iOS drawer will be closed as soon as item is selected, not clicking on Done button.
@ArianHamdi yes, that was the problem. Initially in the code we were setting the value to the object that isn't in the list. Thank you.
Hi, Mine is not key prop issue, infact the key prop is not set.
But what i noticed is as follows:
if i set onValuechange prop to log to console it works but setting the value to state function fails .. drawer closes before clicking on done
Works:
<RNPickerSelect
onValueChange={(val) => {
console.log(val);
}}
placeholder={{label:"Select one", value:"Select one"}}
value={data.state}
style={pickerSelectStyles}
items={states}
Icon={() => {
return <Icon size={20} name="ios-arrow-down" color={colors.black} />;
}}
/>
Does not work:
<RNPickerSelect
onValueChange={(val) => {
setData({
...data,
state: val,
});
}}
placeholder={{label:"Select one", value:"Select one"}}
value={data.state}
style={pickerSelectStyles}
items={states}
Icon={() => {
return <Icon size={20} name="ios-arrow-down" color={colors.black} />;
}}
/>
I can confirm that getting rid of the key
prop resolved my issue.
Same here key
prop solved the issue
Removing the key prop resolved my issue.
any updates on this issue? i don't even use the key prop
any updates on this issue? i don't even use the key prop
For my case.. i was creating a separate function with the picker, then calling it in render.. all i did was to use the picker component inside the render directly...
@theambidextrous did it work? can u give me an example?
i have a separate component with the Picker already
Describe the bug
Picker on iOS selects an item in the list and closes the drawer before button Done is clicked.
To Reproduce
You can see it in this simple example: https://snack.expo.io/@betabit/react-native-picker-select
Select picker, scroll to choose second item. Drawer will be closed before Done button is clicked.
Expected behavior
Selection of the item should be after button Done is clicked, and only then should the drawer close.
Screenshots
n/a Additional details
Reproduction and/or code sample
https://snack.expo.io/@betabit/react-native-picker-select