Last active
September 22, 2018 07:18
-
-
Save leslie-alldridge/f3fc20e27b383446cf3207a7ea960e55 to your computer and use it in GitHub Desktop.
mapDispatchToProps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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