Last active
March 26, 2018 09:57
-
-
Save prichodko/41acd5a629a67b295e8fa892230a837b to your computer and use it in GitHub Desktop.
mapDispatchToProps shortcut
This file contains 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 | |
const mapDispatchToProps = dispatch => ({ | |
showHoverCart: () => dispatch(hoverCartActions.showHoverCart()), | |
hideHoverCart: () => dispatch(hoverCartActions.hideHoverCart()), | |
changeTab: index => dispatch(productActions.changeTab({ index })), | |
zoomIn: isZoomedIn => dispatch(productActions.zoomIn({ isZoomedIn })), | |
toggleNav: navState => dispatch(navActions.toggleNav({ navState })), | |
addToRecentlyViewed: product => | |
dispatch(recentlyViewedActions.addToRecentlyViewed(product)), | |
}) | |
// equals to this | |
// which is much less typing :D | |
const mapDispatchToProps = { | |
showHoverCart: hoverCartActions.showHoverCart, | |
hideHoverCart: hoverCartActions.hideHoverCart, | |
changeTab: productActions.changeTab, | |
zoomIn: productActions.zoomIn, | |
toggleNav: navActions.toggleNav, | |
addToRecentlyViewed: recentlyViewedActions.addToRecentlyViewed, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment