【发布时间】:2019-03-20 03:51:50
【问题描述】:
我有这个动作创建者:
type LoadOpenRequestsResult = ThunkAction<
Promise<void>,
IRootState,
undefined,
LoadOpenRequestsActions
>;
export const loadOpenRequests: ActionCreator<LoadOpenRequestsResult> = () => {
[...]
};
我在我的组件中使用它:
public componentDidMount() {
this.props.loadOpenRequests();
}
我使用 mapDispatchToProps 的对象版本连接我的 React 组件,如下所示:
export default connect(
mapStateToProps,
{ loadOpenRequests }
)(MaintenanceOpenListScreen);
我想在异步操作完成后做一些事情,像这样:
public componentDidMount() {
await this.props.loadOpenRequests();
doSomethingWhenThisAsyncIsDone();
}
但this.props.loadOpenRequests(); 不是 Promise。
这是否意味着我不能使用 mapDispatchToProps 的对象版本?
【问题讨论】:
标签: redux react-redux redux-thunk