【发布时间】:2021-10-14 11:49:08
【问题描述】:
我有三个异步函数,但第三个函数在第二个函数解析之前正在运行。这里有什么问题?
async function getSet () {
//get settings from asyncstorage and setstate
}
async function pairs () {
//fetch data and set another state
}
async function fetchIt () {
//fetch another data and set a third state
}
useEffect(() => {
getSet()
.then(pairs())
.then(fetchIt())
.then(() => {
setLoading(false);
});
}, []);
fetchIt() 在pairs() 之前运行
【问题讨论】:
-
我已经更正了代码,因为我不需要他们的结果。我只想设置状态。
-
我实际上已经纠正了我的问题:)
标签: javascript react-native asynchronous promise