Created
April 27, 2018 17:04
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