Is there any way you could add Promise-based versions of placesAutocompleteService.current.getPlacePredictions and placesAutocompleteService.current.getQueryPredictions in your usePlacesAutocompleteService hook?
This way, users could use the usePlacesAutocompleteService hook inline with promises instead of having to listen to updates to the placePredictions variable inside of a useEffect like you have in your example:
useEffect(() => {
// fetch place details for the first element in placePredictions array
if (placePredictions.length)
placesService?.getDetails(
{
placeId: placePredictions[0].place_id,
},
(placeDetails) => savePlaceDetailsToState(placeDetails)
);
}, [placePredictions]);
Hi @ErrorPro
Is there any way you could add Promise-based versions of
placesAutocompleteService.current.getPlacePredictions
andplacesAutocompleteService.current.getQueryPredictions
in yourusePlacesAutocompleteService
hook?Currently they look like:
but they could be wrapped like this:
This way, users could use the
usePlacesAutocompleteService
hook inline with promises instead of having to listen to updates to theplacePredictions
variable inside of auseEffect
like you have in your example:Thanks! Nick