-
Notifications
You must be signed in to change notification settings - Fork 503
Closed
Description
Possibly duplicate of this issue.
Describe the bug
When onValueChange awaits an async call, the delay causes it to be fired twice. Once from the manual select, and once from getDerivedStateFromProps
To Reproduce
Steps to reproduce the behavior:
- Create a
RNPickerSelect - set
onValueChangeto be an async function that awaits something that takes 1000 ms - Try to change the value
- Value will not change, or it will flicker back and forth
Expected behavior
Only 1 call of onValueChange
Screenshots
n/a
Additional details
- Device: android
- OS: Ubuntu
- react-native-picker-select version: 7.0.0
- react-native version: 0.62.2
- react version: 16.11.0
Reproduction and/or code sample
Example repo here
Suggestion for fix
Awaiting the call here seems to fix the problem. Not sure if this breaks anything else though.
async onValueChange(value, index) {
const { onValueChange } = this.props;
await onValueChange(value, index);
this.setState((prevState) => {
return {
selectedItem: prevState.items[index],
};
});
}
imcyee
Metadata
Metadata
Assignees
Labels
No labels