Skip to content

Instantly share code, notes, and snippets.

@DylanVann
Last active November 6, 2017 17:31
Show Gist options
  • Select an option

  • Save DylanVann/666826211f5396841036becc30334d44 to your computer and use it in GitHub Desktop.

Select an option

Save DylanVann/666826211f5396841036becc30334d44 to your computer and use it in GitHub Desktop.
Redux Container Verbose Example
import { connect } from 'react-redux'
import MyComponent from './MyComponent'
function mapStateToProps(state) {
return {
name: state.user.name,
email: state.user.email,
}
}
function mapDispatchToProps(dispatch) {
return {
onNameChanged: (name) => dispatch({ type: 'NAME_CHANGED', payload: name }),
onEmailChanged: (email) => dispatch({ type: 'EMAIL_CHANGED', payload: email }),
}
}
export default connect(mapStateToProps, mapDispatchToProps)(MyComponent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment