react-google-autocomplete icon indicating copy to clipboard operation
react-google-autocomplete copied to clipboard

Google is not defined

Open Veri5ied opened this issue 3 years ago • 1 comments

While using the package, it works well on local machine but when deployed online, it returns google is not defined and app refuses to load. I am using the useGoogle from your library

Veri5ied avatar Jul 29 '22 11:07 Veri5ied

Would it be possible to send some stack traces?

ErrorPro avatar Aug 18 '22 10:08 ErrorPro

usePlacesAutocompleteService.js?f5a0:108 Uncaught ReferenceError: google is not defined at buildService2 (usePlacesAutocompleteService.js?f5a0:108:7) at eval (usePlacesAutocompleteService.js?f5a0:121:7) at invokePassiveEffectCreate (react-dom.development.js?61bb:23487:1) at HTMLUnknownElement.callCallback (react-dom.development.js?61bb:3945:1) at Object.invokeGuardedCallbackDev (react-dom.development.js?61bb:3994:1) at invokeGuardedCallback (react-dom.development.js?61bb:4056:1) at flushPassiveEffectsImpl (react-dom.development.js?61bb:23574:1) at unstable_runWithPriority (scheduler.development.js?3069:468:1) at runWithPriority$1 (react-dom.development.js?61bb:11276:1) at flushPassiveEffects (react-dom.development.js?61bb:23447:1)

seems it might have been related to me having a blank apiKey, which gets loaded via a fetch. I split the component so that the hook only runs when I have a apiKey and now the problem appears to be solved.

supagu avatar Oct 14 '22 05:10 supagu

Indeed @supagu setting a blank key accidentally causes this error. I haven't tested it with a dynamic key. @ErrorPro it might be good to add a key check and throw an error. This can help catch silly mistakes.

MohammadKurjieh avatar Nov 27 '22 09:11 MohammadKurjieh