react-geolocated icon indicating copy to clipboard operation
react-geolocated copied to clipboard

isGeolocationEnabled returns true even after location is disabled

Open manavpandya1995 opened this issue 2 years ago • 4 comments

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

manavpandya1995 avatar Feb 24 '22 06:02 manavpandya1995

Yes same issue

burhanahmed92 avatar Aug 03 '22 08:08 burhanahmed92

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.

no23reason avatar Aug 06 '22 18:08 no23reason

I am having the same issue too.

fadijabi avatar Jan 29 '24 20:01 fadijabi

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.

fadijabi avatar Jan 29 '24 21:01 fadijabi