ErrorPro / react-google-autocomplete

React components for google places API.
MIT License
476 stars 113 forks source link

onPlaceSelected not called when click on search result item. #98

Closed darkengine closed 3 years ago

darkengine commented 3 years ago

onPlaceSelected props not being called when clicking on search result item.

But you can find a "PlaceService.GetPlaceDetails" network request is done correctly in Chrome's devtool network section.

My code is:

<AutoComplete style={{ width: "90%" }} apiKey={GOOGLE_MAP_API_KEY} onPlaceSelected={place => console.log('place:', place)} options={{ types: ["address"], componentRestrictions: { country: "us" }, }} />

ErrorPro commented 3 years ago

@darkengine just published 2.0.3 where this should be fixed. Let me know if it's still reproduced

darkengine commented 3 years ago

@darkengine just published 2.0.3 where this should be fixed. Let me know if it's still reproduced

Nice! It works now.

One more suggestion: Add denounce when typing may reduce network requests significantly.

ErrorPro commented 3 years ago

@darkengine Hey, it's already done in v2.0.0. There's a hook called useAutocompleteService which has debounce in it.