streamich / react-use

React Hooks — 👍
http://streamich.github.io/react-use
The Unlicense
41.76k stars 3.15k forks source link

useGeolocation shows infinity loading after update to React 18 (only locally) #2380

Open LobodaAndreyEK opened 2 years ago

LobodaAndreyEK commented 2 years ago

For some reason after I updated my project to React 18 and react-use to 17.4, while developing process (on localhost), I have always {loading: true} property. With both options (allowed/disabled)

willkrakow commented 2 years ago

Not sure why your bug only happens in React 18, but this might help:

In almost all browsers the Geolocation API is only available in secure contexts (i.e., over https). Try running your project through ngrok locally and check the https address.

childrentime commented 2 years ago

@LobodaAndreyEK any reproduce demo?

madhenry commented 1 year ago

React strict mode has to be off for this to work.

chucksellick commented 1 year ago

React strict mode has to be off for this to work.

Do you know why this is? Spent forever debugging this issue before I found this thread.

madhenry commented 1 year ago

https://reactjs.org/docs/strict-mode.html - might give a better understanding