-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Could bindActionCreators optionally take a list of action objects? #363
Comments
You can do this with ES7 object spread proposal:
or (vanilla ES6, needs bindActionCreators(Object.assign({}, SomeActions, OtherActions), dispatch) or (ES5, assumes var assign = require('lodash/object/assign');
bindActionCreators(assign({}, SomeActions, OtherActions), dispatch) |
Ah excellent, that's even easier. Thanks! |
🙌 |
This is helpful! Thanks! |
Super helpful! 🌟 |
@gaearon should this possibly be added to the tips section in the |
A pull request is welcome 😉 |
Not sure if this will help anyone, but I was trying to combine my app actions and Actions from import * as AppActions from './actions';
import { Actions } from 'react-native-router-flux';
function mapDispatchToProps(dispatch) {
return { actions: {...bindActionCreators(AppActions , dispatch), ...Actions } };
} |
This is a little confusing because |
We've got a few places in our code where we're passing multiple objects of bound actions into components. It would great to have the optionally pass a list of action objects into
bindActionCreators
.bindActionCreators([SomeActions, OtherActions], dispatch)
The caveat of course would be duplicate actions would get overwritten by the last one processed.
The text was updated successfully, but these errors were encountered: