A cautionary error message: unable to update a state in React on an unmounted component.
Although this may seem harmless, it could signify a memory leak in your application. To resolve this issue, be sure to cancel all subscriptions and synchronous tasks within a useEffect cleanup function.
I was utilizing this functionality for navigating to different scenes once the location had been obtained. However, the warning appeared after successfully navigating to the screen.
useEffect ( () => {
(async () => {
let {status} = await Location.requestPermissionsAsync();
if (status !== 'granted'){
setErrorMsg('Permission to access location has not been granted')
}
let location = await Location.getCurrentPositionAsync({});
const {coords} = location
if (coords) {
const {latitude, longitude} = coords;
let addressResponse: any = await Location.reverseGeocodeAsync({latitude, longitude})
for (let item of addressResponse){
setAddress(item)
let currentAddress = `${item.name},${item.street},${item.postalCode},${item.country}`
setDisplayAddress (currentAddress)
if (currentAddress.length>0){
setTimeout(
() => {
navigate('homeStack')
},1000)
}
return;
}
}else {
}
})();
},)