Skip to content

Instantly share code, notes, and snippets.

@Abazhenov
Last active December 28, 2017 18:00
Show Gist options
  • Save Abazhenov/cae5b13c213be297d10b5d824f63feba to your computer and use it in GitHub Desktop.
Save Abazhenov/cae5b13c213be297d10b5d824f63feba to your computer and use it in GitHub Desktop.
const mapDispatchToProps = (dispatch, ownProps) => ({
getUser(id) {
dispatch(ownProps.getUser(id))
}
})
class MyFancyComponent extends React.Component {
// react things
}
export default connect(() => ({}), mapDispatchToProps)(MyFancyComponent)
/*
BECOMES
*/
import { mapDispatchToProps } from '../myFancyDecorators'
@mapDispatchToProps((dispatch, ownProps) => ({
getUser(id) {
dispatch(ownProps.getUser(id))
}
}))
export default class MyFancyComponent extends React.Component {
// react things
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment