问题描述
我有一个通过<Suspense />
渲染微调器的组件。安装此组件后,将通过fetchQuery
钩子触发useEffect
请求,如下所示:
const VisualComponent = () => {
...
const [foo,setFoo] = useState(null);
useEffect(() => {
const fetchFoo = async () => {
await getFoo().then((someBoolean) => {
if (someBoolean && someOtherCondition) {
setFoo(true);
}
});
}
fetchFoo();
});
return(<Suspense fallback={SomeLoader} />...</Suspense>)
};
和getFoo()
呼叫fetchQuery
:
const getFoo = async () => {
let result;
await fetchQuery(...)
.then((data) => {
result = data;
});
return result;
};
由于某种原因,挂起仅在通过getFoo
触发fetchFoo
时显示加载程序,并停止显示加载程序,而无需等待fetchFoo
完成。
如何让悬念等待fetchFoo
完成?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)