Online_Food_Order_App icon indicating copy to clipboard operation
Online_Food_Order_App copied to clipboard

Landing screen getting issue with utils.UseNavigation()

Open maheshvaradaraj opened this issue 2 years ago • 0 comments

Screenshot 2022-07-08 at 6 26 52 am

code:

import { StyleSheet, Text, View, Image, Dimensions } from 'react-native'
import React, {useState, useReducer, useEffect }from 'react'
import * as Location from 'expo-location';
import { useNavigation } from '../utils'
const screenWidth = Dimensions.get('screen').width
const LandingScreen = () => {
  const { navigate } = useNavigation()
  const [errorMsg, setErrorMsg] = useState("")
  const [address, setAddress] = useState<Location.LocationGeocodedAddress>()
  const [displayAddress, setDisplayAddress] = useState("");
  useEffect(() => {
      (async () => {
        let { status } = await Location.requestForegroundPermissionsAsync();

        if (status !== 'granted') {
          setErrorMsg("Permission is declined")
        }

        let location: any = await Location.getCurrentPositionAsync();
        const { cords } = location

        if (cords) {
          const { latitude, longitude } = cords
          let addressResponse: any = await Location.reverseGeocodeAsync({ latitude, longitude })
          
          let res = addressResponse.map((item: any) => {
            setAddress(item)
            let currentAddress = `${item.name}, ${item.streetAddress}, ${item.city}, ${item.state}, ${item.zipCode}, ${item.country}`
            setDisplayAddress(currentAddress);
            if(currentAddress.length > 0) {
              setTimeout(() => {
                // narvigate('homeStack')
              }, 1000)
            }
            return;
          })
        } else {
          setErrorMsg("Something went wrong ")
        }
      })();
  },[])
export default LandingScreen

maheshvaradaraj avatar Jul 08 '22 05:07 maheshvaradaraj