Skip to content

Instantly share code, notes, and snippets.

@radzionc
Created April 27, 2018 17:04
Show Gist options
  • Save radzionc/4ad1b22d2c61fcdd6b715e9073aec367 to your computer and use it in GitHub Desktop.
Save radzionc/4ad1b22d2c61fcdd6b715e9073aec367 to your computer and use it in GitHub Desktop.
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