Online_Food_Order_App
Online_Food_Order_App copied to clipboard
Landing screen getting issue with utils.UseNavigation()
![Screenshot 2022-07-08 at 6 26 52 am](https://user-images.githubusercontent.com/46704597/177925379-af3ba2bb-0f44-435c-9a49-8e06064ce0f6.png)
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