Skip to content

Instantly share code, notes, and snippets.

@timbuckley
Last active July 20, 2016 15:28
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 timbuckley/ffe6a2521408c3954b2f1820b1d22e7c to your computer and use it in GitHub Desktop.
Save timbuckley/ffe6a2521408c3954b2f1820b1d22e7c to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import Settings from '../components/scenes/settings'
import * as settingActions from '../actions/settings'
import * as signUpActions from '../actions/sign-up'
import * as loginActions from '../actions/login'
import * as routerActions from '../actions/router'
class SettingsContainer extends Component {
static propTypes = {
state: React.PropTypes.object.isRequired,
actions: React.PropTypes.object.isRequired
}
render() {
const { state, actions } = this.props
return (
<Settings
state={{...state}}
actions={{...actions}}
/>
)
}
}
// map global state to component properties
function mapStateToProps(state) {
return {state: state}
}
// map global state to component properties
function mapDispatchToProps(dispatch) {
const allActions = {
...loginActions,
...settingActions,
...signUpActions,
...routerActions
}
return {
actions: bindActionCreators(allActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(SettingsContainer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment