Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

unmounted component error on react native

$
0
0

warning error: can't perform a react state update on an unmounted component.

This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and synchrounous taks in a useEffect cleanup function.

I was using it to navigate to different scenes once the location had been captured. But it's shown up the warning after it's navigate to the screen

useEffect ( () => {        (async () => {            let {status} = await Location.requestPermissionsAsync();            if (status !== 'granted'){                setErrorMsg('Permission to access location is not 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 {            }        })();},)

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>