ErrorPro / react-google-autocomplete

React components for google places API.
MIT License
462 stars 114 forks source link

Added check for `google.maps` in script loader when script element already exists #237

Closed marik22312 closed 2 weeks ago

marik22312 commented 2 weeks ago

Got same error as in issue #176

After some research found that this error appears when we have 2 components that use the usePlacesAutocompleteService hook. and it appears only for the 2nd component.

this is caused because on the 2nd load of the component, the google API is partially loaded, and we have google on the global scope, but we still don't have the google.maps object.

adding a check that google.maps object exists seem to solve this issue

marik22312 commented 2 weeks ago

Figure out it wont work, will think of a perm solution