My app requests permission to access a user's location in Screen A, so their location renders on a map in Screen B. When navigating to Screen B, I'm hit with a promise rejection, and the map not loading.

Below is my code:

Spins until current location permissions are granted

const renderLoading = () =>  {
    if (isLoading) {
      return (         
          <View style = {styles.indicator}>
            <ActivityIndicator
              color = 'black'
              size = 'large'
              animated = {false}
            />
            <Text style = { styles.text }>{i18n.t('locate')}</Text>
          </View>
          );
          }else {
            return null;
          }
    }

UseFocusEffect that gets geolocation

useFocusEffect( 
      React.useCallback(()=> {
        let isActive = true;
          
          const fetchGeoPosition = async() => {
             navigator.geolocation.getCurrentPositionAsync( //claims undefined is not a function
              position => { 
                if (isActive){
                  setUserLatitude(position.coords.latitude);
                  setUserLongitude(position.coords.longitude);
                  setPositionError(null);
                  console.log('Location Accessed')
                } 
                setIsLoading(false)
              }, 

              error => isActive && setPositionError(error.message),
              {enableHighAccuracy: true, timeout: 0, maximumAge: 1000} 
            ); 
          }

How I deploy onto the map

<View style = {styles.container}>
          {(renderLoading())}

            <View style = {styles.header}>
       
            <MapView
                provider={PROVIDER_GOOGLE}
                style={styles.map}
                region= {{
                  latitude: user_latitude,
                  longitude: user_longitude,
                  latitudeDelta: 0.1451,
                  longitudeDelta: 0.1451
                }}
            >
            <Marker 
              coordinate={ 
                {latitude: user_latitude,
                 longitude: user_longitude,
                 error: position_error,
                }}
            />
        </MapView>
0

There are 0 answers