我无法卸载这个请帮忙,请告诉我如何卸载 useEffect 中的函数
警告:无法执行 React 状态 更新未安装的组件。这是一个空操作,但它表明您的应用程序中存在内存泄漏。要解决此问题,请取消 useEffect 清理函数中的所有订阅和异步任务。
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)
}
}```