ErrorPro / react-google-autocomplete

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

google is not defined at refreshSessionToken #167

Open sayad-mallllek opened 2 years ago

sayad-mallllek commented 2 years ago

I am using react autocomplete with session tokens and I had to use a useeffect on the main page load to add a session token because by default is comes null from usePlacesService

useEffect(() => { refreshSessionToken(); return () => {}; }, []);

I am using Nextjs and it is giving this error framework-79bce4a3a540b080.js:1 ReferenceError: google is not defined at refreshSessionToken (8345-36847ac2dcf11485.js:1:16048) at 6436-17e866bb9800252e.js:1:14460 at Ui (framework-79bce4a3a540b080.js:1:104667) at t.unstable_runWithPriority (framework-79bce4a3a540b080.js:1:129355) at Ql (framework-79bce4a3a540b080.js:1:44986) at Fi (framework-79bce4a3a540b080.js:1:104128) at bi (framework-79bce4a3a540b080.js:1:95618) at framework-79bce4a3a540b080.js:1:45209 at t.unstable_runWithPriority (framework-79bce4a3a540b080.js:1:129355) at Ql (framework-79bce4a3a540b080.js:1:44986)

And it causes a client side exception

ErrorPro commented 2 years ago

Will check it asap

pymanish commented 1 year ago

I got the same error. I wasn't providing the apiKey that's why this error occurred. You should check if you're providing apiKey or not.