我想构建一个 React 组件,它在componentDidMount
.
这是函数当前的样子(用 编写TypeScript
):
async componentDidMount(): Promise<void> {
try {
const { props: { teamId }, state: { } } = this;
const awaitableData = await UrlHelper.getDataAsync("some-fancy-url");
// ... do something with awaitableData
} catch(e) {
console.log("Some error occured");
throw e;
}
}
所述render
-function返回标记包裹在一个ErrorBoundary
组件,它已componentDidCatch
实现。但是,当等待的调用被拒绝并且我最终进入catch
-block时,这永远不会被调用/触发。
我在这里错过了什么?