mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-27 19:42:11 +10:00
Fix setState within setState
This commit is contained in:
parent
1cb05da531
commit
cfeeca49b4
1 changed files with 14 additions and 7 deletions
|
|
@ -375,13 +375,21 @@ class LocationAutocompleteInputGoogleMaps extends Component {
|
|||
}
|
||||
|
||||
handlePredictionsSelectEnd(index) {
|
||||
this.setState(prevState => {
|
||||
if (!prevState.isSwipe) {
|
||||
this.selectItem(index);
|
||||
this.finalizeSelection();
|
||||
let selectAndFinalize = false;
|
||||
this.setState(
|
||||
prevState => {
|
||||
if (!prevState.isSwipe) {
|
||||
selectAndFinalize = true;
|
||||
}
|
||||
return { selectionInProgress: false, touchStartedFrom: null, isSwipe: false };
|
||||
},
|
||||
() => {
|
||||
if (selectAndFinalize) {
|
||||
this.selectItem(index);
|
||||
this.finalizeSelection();
|
||||
}
|
||||
}
|
||||
return { selectionInProgress: false, touchStartedFrom: null, isSwipe: false };
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
@ -503,5 +511,4 @@ LocationAutocompleteInputGoogleMaps.propTypes = {
|
|||
inputRef: func,
|
||||
};
|
||||
|
||||
|
||||
export default LocationAutocompleteInputGoogleMaps;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue