我有以下代码 -
import React,{useEffect} from 'react'
function MultiCallFile() {
function AddOneToNumber(number){
setTimeout(function(){
console.log("in");
number++;
console.log(number);
return number;
}, 5000);
}
function SubstractOneToNumber(number){
return number-1;
}
useEffect(() => {
async function PerformOperations()
{
console.log("Started");
var number= await AddOneToNumber(1);
console.log(number);
number = await AddOneToNumber(number);
console.log(number);
number = SubstractOneToNumber(number);
console.log(number);
}
PerformOperations();
}, [])
return (
<div>
</div>
)
}
export default MultiCallFile
我想等待调用 AddOneToNumber 直到前一个调用到来。 我变得未定义 -