Created
April 27, 2018 17:04
-
-
Save radzionc/4ad1b22d2c61fcdd6b715e9073aec367 to your computer and use it in GitHub Desktop.
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
export const connectTo = (mapStateToProps, actions, Component) => { | |
const mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch) | |
return connect(mapStateToProps, mapDispatchToProps)(Component) | |
} | |
const doSomeStaff = createAction() | |
export default connectTo( | |
// map state to props | |
state => state.something, | |
// object with actions | |
{ doSomeStaff }, | |
// component | |
({ someStaff, doSomeStaff }) => ( | |
<button onClick={doSomeStaff}>{someStaff}</button> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment