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

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?
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:
- You might have mismatching versions of React and the renderer (such as React DOM)
- You might be breaking the Rules of Hooks
- 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 :)
The issue is that the browser requires SSL for this to work, here is one quick solution:
HTTPS
A really simple solution is mkcert
brew install mkcertmkcert -installmkcert 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.
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...