ErrorPro / react-google-autocomplete

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

Multiple google components on same project #192

Closed jacobpastorek closed 1 year ago

jacobpastorek commented 1 year ago

Hello, I have multiple libraries that use google services, yours and google-map-react

if content of google-map-react loads first this error will occur when i try to use autocomplete input ->

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'AutocompleteService') at buildService (usePlacesAutocompleteService.js:110:1) at usePlacesAutocompleteService.js:118:1

if react-google-autocomplete is loaded first, map shown by second library doesn't have markers and another warnings occur. is there possibility to somehow initialize all google services first, than use both libraries at the same time ?

in both of them is place for "API_KEY" in their components so i'm guessing the problem is loading same services twice?

Thanks

jacobpastorek commented 1 year ago

found solution here: Solution