我目前正在拼命尝试在React应用程序中包含一个真正的异步while循环。但是UI每次都会挂起。
到目前为止,我一直试图在包含while循环的componentDidMount方法中调用异步函数。
componentDidMount() {
this.doTheMath();
}
async doTheMath() {
while (true) {
await this.logg('doTheMath');
}
}
logg(msg) {
return new Promise((resolve, _) => {
console.log('logg', msg);
resolve();
});
}
有人可以帮我吗?有人有类似的问题吗?