react-geolocated
react-geolocated copied to clipboard
isGeolocationEnabled returns true even after location is disabled
I want to check that if location is disabled, i want to surpass the location prompt
But "isGeolocationEnabled" returns "true" always which seems a weird issue
@no23reason Please check this accordingly
Yes same issue
Hi @manavpandya1995 and @burhanahmed92 can you please share some more details? I tried reproducing this locally and when I block the geolocation, the isGeolocationEnabled
correctly returns false
.
I am having the same issue too.
I think I know the issue...
the hook does not remember some of the props sent to it.. example, suppressLocationOnMount is not in the dependencies of the useCallback... and thus, weird state issues...
useEffect(() => { if (!suppressLocationOnMount) { getPosition(); }
return () => {
cancelUserDecisionTimeout();
if (watchPosition && watchId.current) {
geolocationProvider?.clearWatch(watchId.current);
}
};
}, [permissionState]); // eslint-disable-line react-hooks/exhaustive-deps
you are expecting that we send either true or false, but inreality we send these based on states too.