michalchudziak / react-native-geolocation

Geolocation APIs for React Native
MIT License
1.31k stars 228 forks source link

State is not updating using setState in geolocation function #277

Open Ehsan5g opened 11 months ago

Ehsan5g commented 11 months ago

Environment

I used Geolocation.getCurrentPosition , but my state is not updated

code :

Geolocation.getCurrentPosition(
            (position)=> {
              console.log(position);
              setLocation(position);
            },
            undefined,
            {
              maximumAge: 0,
              timeout: 5000,
              enableHighAccuracy: true,
            },
          );

Platforms

Versions

Description

Reproducible Demo

kr396 commented 3 months ago

Facing same issue