Skip to content

Instantly share code, notes, and snippets.

@Abazhenov
Created December 28, 2017 17:09
Show Gist options
  • Save Abazhenov/a553127aaf9067285c005231d897521f to your computer and use it in GitHub Desktop.
Save Abazhenov/a553127aaf9067285c005231d897521f to your computer and use it in GitHub Desktop.
connect without decorator
import React from 'react'
import { connect } from 'react-redux'
class MyFancyComponent extends React.Component {
// react things in here
}
const mapStateToProps = (state) => {
return { users: state.users };
}
const mapDispatchToProps = (dispatch, ownProps) {
return {
getUser(id) {
dispatch(ownProps.getUser(id))
}
}
}
export default connect(mapStateToProps, mapDispatchToProps)(MyFancyComponent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment