Skip to content

Instantly share code, notes, and snippets.

@cacheflow
Created January 14, 2016 00:23
Show Gist options
  • Save cacheflow/3e5fd3a748c7a015f1db to your computer and use it in GitHub Desktop.
Save cacheflow/3e5fd3a748c7a015f1db to your computer and use it in GitHub Desktop.
import React, { Component, PropTypes } from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import Header from '../components/Header'
import MainSection from '../components/MainSection'
import * as TodoActions from '../actions/todos'
class App extends Component {
render() {
const { todos, actions } = this.props
return (
<div>
<Header addTodo={actions.addTodo} />
<MainSection todos={todos} actions={actions} />
</div>
)
}
}
App.propTypes = {
todos: PropTypes.array.isRequired,
actions: PropTypes.object.isRequired
}
function mapStateToProps(state) {
return {
todos: state.todos
}
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators(TodoActions, dispatch)
}
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(App)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment