【发布时间】:2021-05-30 18:03:47
【问题描述】:
所以我有一个运行异步的函数,所以把异步放在useEffect里面,下面是我的代码
useEffect(() => {
const data = async () => {
const data = await getAllVertification();
if (!data.status) {
} else {
setAlldata(data.data);
setLoadingAction([]);
let tmp = [];
for (const element of data.data) {
tmp.push({ status: false });
}
setLoadingAction(tmp);
}
};
data();
}, [update]);
但像这样逐渐减弱
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.
谁能给我解释一下?
【问题讨论】:
-
错误/警告具体有什么不清楚的地方?