Skip to content

Instantly share code, notes, and snippets.

@cellog
Last active January 14, 2017 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cellog/851a0a521b2704c03dc30b4d62cb5e42 to your computer and use it in GitHub Desktop.
Save cellog/851a0a521b2704c03dc30b4d62cb5e42 to your computer and use it in GitHub Desktop.
accessing react-router props in a redux connected component
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