Skip to content

Instantly share code, notes, and snippets.

@kishanio
Created May 5, 2017 13:48
Show Gist options
  • Save kishanio/8265cc1edaf3e56b4ec8a837a1f2e384 to your computer and use it in GitHub Desktop.
Save kishanio/8265cc1edaf3e56b4ec8a837a1f2e384 to your computer and use it in GitHub Desktop.
Redux : Map Dispatch Props Shorthand
const mapDispatchToProps = (dispatch) => ({
onTodoClick(id) {
dispatch(toggleTodo(id));
},
});
const VisibleTodoList = withRouter( connect(
mapStateToProps,
mapDispatchToProps
)(TodoList) );
// can be re written as.
const VisibleTodoList = withRouter( connect(
mapStateToProps,
{ onTodoClick: toggleTodo }
)(TodoList) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment