Skip to content

Instantly share code, notes, and snippets.

@leslie-alldridge
Last active September 22, 2018 07:18
Show Gist options
  • Save leslie-alldridge/f3fc20e27b383446cf3207a7ea960e55 to your computer and use it in GitHub Desktop.
Save leslie-alldridge/f3fc20e27b383446cf3207a7ea960e55 to your computer and use it in GitHub Desktop.
mapDispatchToProps
//this function will return multiple functions (actions) to props. That's why it's named map dispatch to props.
//Dispatch is a way to say "go and do this thing for me"
//
//Using this code in react will allow us to say
//this.props.deleteBagDB(id), this.props.showItems(id), this.props.getBags()
//
//Remember: Import these action functions into your component first.
function mapDispatchToProps(dispatch) {
return {
deleteBagDB: id => {
dispatch(deleteBagDB(id));
},
showItems: id => {
dispatch(showItems(id));
},
getBags: () => {
dispatch(getBags());
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment