I am not able to unmount this please help, please tell me how to unmount a function in useEffect
Warning: 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 asynchronous tasks in a useEffect cleanup function.
checkLoginState();
},[]);
const checkLoginState = () =>{
if(user.length > 0 ){
fetch(`${Config.SERVER_KEY}/api/users/profile`, {
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'Authorization': `Bearer ${user}`
}
}).then((response) => response.json())
.then((json) => {
console.log(json)
if(json.success === true){
setUserData(json.data)
setData(json)
setUser(true)
setLoading(false)
} else if (json.msg === 'Token has expired'){
refresh();
} else {
console.log(json)
alert('Failed to access data')
navigation.navigate('main')
}
})
.catch((error) => {
console.log(error)
});
} else {
setLoading(false)
}
}```