Skip to content

Instantly share code, notes, and snippets.

@joedski
Last active May 28, 2017 21:00
Show Gist options
  • Save joedski/74eec0241a904c87d768e2c042f9f84c to your computer and use it in GitHub Desktop.
Save joedski/74eec0241a904c87d768e2c042f9f84c to your computer and use it in GitHub Desktop.
Javascript: Redux: Dispatching Multiple Actions: React Redux Example
export default connect(
null,
dispatch => ({
doAllTheThings: dispatch(multiAction([
doThisThing(),
doThatThing({ computer: 'over' }),
doTheOtherThing('foo'),
])),
}),
)(props => (
<button onClick={props.doAllTheThings}>Do ALL the things!</button>
));
export default connect(
null,
dispatch => ({
// look ma, no extra action
doAllTheThings: dispatch([
doThisThing(),
doThatThing({ computer: 'over' }),
doTheOtherThing('foo'),
]),
}),
)(props => (
<button onClick={props.doAllTheThings}>Do ALL the things!</button>
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment