Skip to content

Instantly share code, notes, and snippets.

@mrblueblue
Created May 31, 2016 18:34
Show Gist options
  • Select an option

  • Save mrblueblue/0d427298b7f4d5d9ebdd16e059f2fb86 to your computer and use it in GitHub Desktop.

Select an option

Save mrblueblue/0d427298b7f4d5d9ebdd16e059f2fb86 to your computer and use it in GitHub Desktop.
import {compose, getContext, mapProps} from 'recompose'
function connect(mapStateToProps, mapDispatchToProps) {
return compose(
getContext({
store: Proptypes.shape({
getState: Proptypes.func,
dispatch: Proptypes.func,
subscribe: Proptypes.func,
})
}),
mapProps(({store, ...rest}) => Object.assign(
{ },
{...rest},
mapStateToProps(store.getState(), {...rest}),
mapDispatchToProps(store.dispatch, {...rest})
))
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment