ErrorPro / react-google-autocomplete

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

no callback function warning #200

Closed FredSoderberg closed 1 year ago

FredSoderberg commented 1 year ago

Loading the Google Maps JavaScript API without a callback is not supported: https://developers.google.com/maps/documentation/javascript/url-params#required_parameters

We are receiving this warning when we are using the usePlacesService. This warning seems to have popped up just recently for us because we haven't seen it during implementation or in staging environments and now it appears everywhere.

ErrorPro commented 1 year ago

@FredSoderberg can y try to use @2.7.1 version? If that doesn't help then we would probably have to look into the google's lib

bwarni commented 1 year ago

@FredSoderberg can y try to use @2.7.1 version? If that doesn't help then we would probably have to look into the google's lib

@ErrorPro I'm receiving the same error using usePlacesWidget on version @2.6.1. That said, the functionality doesn't seem to be broken at all and the error persists after updating to version @2.7.1

patoaesteve commented 1 year ago

Hi! I was using version 2.4.0 until yesterday without any problems (). Today i'm having the same error mentioned (Loading the Google Maps JavaScript API without a callback is not supported: https://developers.google.com/maps/documentation/javascript/url-params#required_parameters) . Same with latest version

solarpush commented 1 year ago

Hi, a solution for this err ? -v 2.7.1 || 2.6.1 same error : Loading the Google Maps JavaScript API without a callback is not supported:

usePlaceWidget.js ~line58, var handleLoadScript = (0, _react.useCallback)(function () { return (0, _utils.loadGoogleMapScript)(googleMapsScriptBaseUrl, googleMapsScriptUrl); }, [googleMapsScriptBaseUrl, googleMapsScriptUrl]);

is the useCallback, but i dont know callback contents needed. If help you for patch it , thanks for this package is very easy to use.

ananth99 commented 1 year ago

can confirm that we're also facing the same issue for 2.6.0 since the last 3 days

FredSoderberg commented 1 year ago

@FredSoderberg can y try to use @2.7.1 version? If that doesn't help then we would probably have to look into the google's lib

We tested 2.7.1 and 2.7.2 but to no avail. We will switch to manually loading the api just to be sure that functionality is preserved over time. I can also mention that even though we receive this warning we cant detect any other problems.

violy commented 1 year ago

Same issue on 2.7.2. I've patch this with this code

window && (window._gmapsapicb = () => {});
const {
  // ...
} = usePlacesService({
  apiKey: MY_API_KEY + "&callback=_gmapsapicb",
});

where _gmapsapicb is an arbitrary noop callback function name…

surefiresolutions commented 1 year ago
  1. It appears as of 1/21/23 (I think I read that) Google throws errors if no callback is included in the parameters when loading the Google Maps API script
  2. A workaround is to omit the apiKey parameter and include the script call (with your API Key and callback function) manually
  3. It would be great if the next package update includes a default callback being passed with an optional parameter for including a custom callback function

For now I think I am ignoring it. I am hopeful the package will be updated soon. Please correct me if I am wrong about any of this. Thank you!

gmwill934 commented 1 year ago

I get the same warning, still, everything seems to work

ErrorPro commented 1 year ago

Merged the fix provided by @arcdev1 in v2.7.3, please give it a try