在组件的useEffect中做了一个清理功能,但是我仍然收到this警告消息吗? 有什么想法吗?
我的useEffect
useEffect(() => {
let mounted = true
if (mounted) readPost(`${C.API_ENDPOINT}/posts/${id}`)
if (mounted && (status === 'success')) setSuccessMsg(true)
window.addEventListener('click', () => {
setSuccessMsg(false)
resetStatus()
})
return () => {
mounted = false
window.removeEventListener('click', () => {
setSuccessMsg(false)
resetStatus()
})
}
}, [readPost, resetStatus, id, status])