WebStorm 警告: Promise returned from xxx is ignored 解决办法

WebStorm 提示内容:

Promise returned from xxx is ignored less... (Ctrl+F1) 
This inspection reports function calls that return a Promise that is not later used. These are usually unintended and indicate an error.

 

这是因为调用的函数加了async, 而 async 声明的函数返回的是一个promise.

在调用这个函数前加一个await声明就可以了, 同时await的这个方法段也要添加async声明才能生效.

async componentDidMount() {
  await Common.checkSth();
}

 

你可能感兴趣的:(reactjs,es6,javascript,reactjs,es6,javascript)