首页 > 解决方案 > bluebird.js 等待 Promise.all(); 在处理程序警告中创建了一个承诺

问题描述

async-await我希望同时开始的多个承诺的正确方法是什么。我在做await Promise.all(...),但是...

我收到一个烦人的警告:

Warning: a promise was created in a handler at (path) but was not returned from it
at new Promise (path)
at MyComponent.<anonymous> (path)
at MyComponent.componentDidMount (path)
async componentDidMount() {
    await this.fetchAB();
}
async fetchAB() {
    const [a, b] = await Promise.all([
        new Promise(function pA(r) { return r('a') }),
        new Promise(function pB(r) { return r('b') }),
    ]);
    console.log(a, b);
}

使用 bluebird 覆盖承诺3.7.2(最近的)。通天塔/核心7.5.4

我已经尽一切努力使警告静音,它非常嘈杂,并且导致控制台加载非常缓慢。即将禁用它BLUEBIRD_W_FORGOTTEN_RETURN...

标签: javascriptpromiseasync-awaitbabeljsbluebird

解决方案


推荐阅读