【发布时间】:2018-11-29 18:24:14
【问题描述】:
我想使用mapDispatchToProps 的简写符号,但是当我替换老式的bindActionCreators 策略时
function mapDispatchToProps(dispatch: Dispatch<any>): PropsFromDispatch {
return {
fetchStuff: () => dispatch(fetchStuffAction()),
};
}
....
export default connect(mapStateToProps, mapDispatchToProps)(MyComponent);
使用mapDispatchToProps 速记对象语法
const actions = {
fetchStuff: fetchStuffAction,
};
...
export default connect(mapStateToProps, actions)(MyComponent);
我从流类型检查器收到以下投诉...
Cannot call connect because:
• Either a callable signature is missing in object literal [1] but exists in MapDispatchToProps [2].
• Or a callable signature is missing in object literal [1] but exists in MapDispatchToProps [3].
有什么想法吗?
react-redux v5.0.7
flow-bin v0.69.0
【问题讨论】:
-
请贴一些相关代码
-
查看Github issue and OP has already looked there and commented 时的尴尬时刻。您介意发布您拥有的 libdef 版本吗?我假设
react-redux_v5.x.x.js但想确定。
标签: javascript redux flowtype