Skip to content
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
Closed

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

geminiyellow opened this issue Sep 3, 2015 · 2 comments

Comments

@geminiyellow
Copy link

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
Copy link
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 has been minimized.

@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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants