我正在将代码迁移到
React v16.0
我有个困惑,我能用吗
componentDidCatch
以捕获操作调用引发的错误。首先,让我澄清一下,这个问题不是
componentDidCatchNotWorking
.
我的行动要求如下:
export default {
getEmployeeList() {
return function (dispatch) {
commonApi.getEmployeeList()
.then((response) => {
}).catch((reasonObj: any) => {
throw new Error('Error');
});
};
}
现在在我的组件中,我将此操作称为:
componentWillMount() {
this.props.actions.getEmployeeList();
}
EmployeeList组件的呈现代码为:
render(){
return (
<div className="container">
<ErrorBoundary>
<EmployeeList/>
</ErrorBoundary>
)
}
EmployeeList
是我调用动作的组件。现在我的困惑是,我能在下面的帮助下捕获从操作到组件的异常吗?
组件未捕获
. 请帮帮我,有没有可能?