New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can i wrap multi actionCreators into one props with name? #89

Closed
geminiyellow opened this Issue Sep 3, 2015 · 2 comments

Comments

3 participants
@geminiyellow

geminiyellow commented Sep 3, 2015

We can

Inject todoActionCreators as todoActions, and counterActionCreators as counterActions

Inject todoActionCreators and counterActionCreators together as actions

now.

can i Inject todoActionCreators as todoActions, and counterActionCreators as counterActions, and then together as actions?

{
  actions: {
    todoActions,
    counterActions,
  }
} 
@gaearon

This comment has been minimized.

Show comment
Hide comment
@gaearon

gaearon Sep 3, 2015

Contributor

Yes. It's not magic: you can do anything you want.

import * as todoActions from './todoActions';
import * as counterActions from './counterActions';
import { bindActionCreators } from 'redux';

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

function mapDispatchToProps(dispatch) {
  return {
    actions: {
      todoActions: bindActionCreators(todoActions, dispatch),
      counterActions: bindActionCreators(counterActions, dispatch)
    }
  };
}

export default connect(mapStateToProps, mapDispatchToProps)(TodoApp);
Contributor

gaearon commented Sep 3, 2015

Yes. It's not magic: you can do anything you want.

import * as todoActions from './todoActions';
import * as counterActions from './counterActions';
import { bindActionCreators } from 'redux';

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

function mapDispatchToProps(dispatch) {
  return {
    actions: {
      todoActions: bindActionCreators(todoActions, dispatch),
      counterActions: bindActionCreators(counterActions, dispatch)
    }
  };
}

export default connect(mapStateToProps, mapDispatchToProps)(TodoApp);
@a-m-dev

This comment was marked as outdated.

Show comment
Hide comment
@a-m-dev

a-m-dev Aug 6, 2018

can we have it like all in one place ??? something like:

function mapDispatchToProps(dispatch) {
  return {
    actions: {
      actions: bindActionCreators({ todoActions, counterActions }, dispatch),
    }
  };
}

can we ?????

a-m-dev commented Aug 6, 2018

can we have it like all in one place ??? something like:

function mapDispatchToProps(dispatch) {
  return {
    actions: {
      actions: bindActionCreators({ todoActions, counterActions }, dispatch),
    }
  };
}

can we ?????

@reduxjs reduxjs locked and limited conversation to collaborators Aug 6, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.