Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Violation] Only request geolocation information in response to a user gesture #7

Open
gkrinc opened this issue Jan 20, 2020 · 3 comments

Comments

@gkrinc
Copy link

gkrinc commented Jan 20, 2020

I'm seeing an this Violation increasing continuously on the page [Violation] Only request geolocation information in response to a user gesture.

Screen Shot 2020-01-20 at 2 02 43 PM

This is my usage of usePosition

const {
    latitude: userLatitude,
    longitude: userLongitude,
    error: geoLocationError,
  } = usePosition(true, {
    enableHighAccuracy: CONSTANTS.locationServices.enableHighAccuracy, // true
    timeout: CONSTANTS.locationServices.timeout, // 60000
  });

This seems to only be happening in Chrome. Safari and Firefox aren't reporting the same violation. I did notice in Firefox though that if I didn't check the box to remember me allowing location services the box repeatedly popped up to ask me to allow. Is this related?

@michaeldu1
Copy link

michaeldu1 commented May 11, 2020

Hi @gkrinc , I keep getting this error:
`Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app
    See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.`

I'm doing a similar usage of usePosition, so I don't think I'm breaking any hooks rules (but I might be)? Did you run into this issue at all/know of a fix? thanks :)

@Wkasel
Copy link

Wkasel commented Jul 21, 2020

The issue is that the browser requires SSL for this to work, here is one quick solution:

HTTPS

A really simple solution is mkcert

  1. brew install mkcert
  2. mkcert -install
  3. mkcert localhost -> The certificate is at "./localhost.pem" and the key at "./localhost-key.pem" ✅
  • QuickStart: (yarn | npm run) start:https
  • Custom SSL Cert: HTTPS=true SSL_CRT_FILE=./localhost.pem SSL_KEY_FILE=./localhost-key.pem npm start

This will setup and install a SSL certificate, and allow you to run GeoLocation.

@Fabio-TI
Copy link

Eu estava encontrando o mesmo problema utilizando o chrome. Tentei também no safari e deu o mesmo erro.
Sem esperança, tentei no edge, e num é que apesar da marcação dos erros, eu consegui debugar...?
Ainda não encontrei o motivo causal de porque o Chrome e safari bugaram...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants