ErrorPro / react-google-autocomplete

React components for google places API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple google components on same project

jacobpastorek opened this issue · comments

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

found solution here: Solution