Created
January 14, 2016 00:23
-
-
Save cacheflow/3e5fd3a748c7a015f1db to your computer and use it in GitHub Desktop.
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 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