ErrorPro / react-google-autocomplete

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

component blocking the website load #160

Closed cheymonty closed 2 years ago

cheymonty commented 2 years ago

My places api key is correct and has billing enabled. I am importing like this import Autocomplete from 'react-google-autocomplete'; When I put this in my code: <Autocomplete apiKey={API_KEY} onPlaceSelected={(place) => { console.log(place); }} /> the website freezes and gets stuck in a loop until the website crashes.

ErrorPro commented 2 years ago

You can try an alternative way of adding the google map script and see if it still breaks your website

pifantastic commented 2 years ago

I am also seeing this issue. It seems to be specific to React v18.

Here is an example:

https://codesandbox.io/s/snowy-tree-4v8pz8?file=/src/App.js

When you uncomment the <input>, the page crashes. I suspect some sort of infinite loop, but I haven't had time to dig into the details.

pifantastic commented 2 years ago

@ErrorPro would you be okay re-opening this issue given the repro I provided above?

ErrorPro commented 2 years ago

@pifantastic Of course, I'll check it asap and make sure its fixed

ErrorPro commented 2 years ago

Found out the issue. I will try to fix it asap and ship a new version.

jmferreiratech commented 2 years ago

@ErrorPro, is there anything we can do to help? I'm facing the same issue.

ErrorPro commented 2 years ago

@jmferreiratech Hey! I am terrible busy these days with the work related projects. If you can just check why the mutation observer hangs the render that would be helpful.

jmferreiratech commented 2 years ago

@pifantastic and @cheymonty, I've noted that the issue happens only on StrictMode. Could you please confirm that is the case for you too?

cheymonty commented 2 years ago

@jmferreiratech Yes the component works when not in StrictMode!

BrightonNgema commented 2 years ago

Has this been fixed?

ErrorPro commented 2 years ago

@BrightonNgema @cheymonty @jmferreiratech Can you guys try out 2.7.0? I wrapped the problematic stuff into a condition to not work on react 18. It was a workaround right from the start, so no wonder it caused the issue. Meantime I'll take a deeper look into the original issue and try to come up with a more robust fix.