Last active
November 6, 2017 17:31
-
-
Save DylanVann/666826211f5396841036becc30334d44 to your computer and use it in GitHub Desktop.
Redux Container Verbose Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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