Reactjs 如何将多个动作绑定到其中一个道具对象装载点

Reactjs 如何将多个动作绑定到其中一个道具对象装载点,reactjs,redux,react-redux,Reactjs,Redux,React Redux,当我使用react-redux时,我希望使用下面的风格 this.props.http.list() this.props.http.detail() this.props.http.create() 如何将多个动作绑定到道具 谢谢。如上所述: 使用mapDispatchToProps将组件函数与redux中的action creator绑定tks,但我想在props中获取集合操作,例如:tks,但我想在props中获取集合操作,例如:this.props.http.list()、this.p

当我使用react-redux时,我希望使用下面的风格

this.props.http.list()
this.props.http.detail()
this.props.http.create()
如何将多个动作绑定到道具

谢谢。

如上所述:


使用
mapDispatchToProps
将组件函数与redux中的action creator绑定

tks,但我想在props中获取集合操作,例如:tks,但我想在props中获取集合操作,例如:this.props.http.list()、this.props.http.create()。我已经编辑了问题描述,都在那里。如果您的操作创建者将返回具有
列表
创建
详细信息
功能的对象,那么您将能够使用
mapDispatchToProps
仅允许您调用这些操作而不调用dispatch
import * as todoActionCreators from './todoActionCreators'
import * as counterActionCreators from './counterActionCreators'
import { bindActionCreators } from 'redux'

function mapStateToProps(state) {
  return { todos: state.todos }
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators(Object.assign({}, todoActionCreators, counterActionCreators), dispatch)
}

export default connect(mapStateToProps, mapDispatchToProps)(TodoApp)