Last active
January 14, 2017 07:23
-
-
Save cellog/851a0a521b2704c03dc30b4d62cb5e42 to your computer and use it in GitHub Desktop.
accessing react-router props in a redux connected component
This file contains 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 Component from './Component' | |
import * as actions from './actions' | |
function mapStateToProps(state, props) { | |
return { | |
year => props.year || state.year | |
} | |
} | |
function mapDispatchToProps(dispatch) { | |
return { | |
setYear: year => dispatch(actions.setYear(year)) | |
} | |
} | |
export default connect(mapStateToProps, mapDispatchToProps)(Component) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment