redux-devtools/examples/todomvc/containers/TodoApp.js

34 lines
753 B
JavaScript
Raw Normal View History

2015-07-14 22:46:44 +03:00
import React, { Component } from 'react';
2015-08-07 19:49:40 +03:00
import { connect } from 'react-redux';
2015-07-14 22:46:44 +03:00
import { bindActionCreators } from 'redux';
import Header from '../components/Header';
import MainSection from '../components/MainSection';
import * as TodoActions from '../actions/TodoActions';
2015-08-07 19:49:40 +03:00
class TodoApp extends Component {
2015-07-14 22:46:44 +03:00
render() {
2015-08-07 19:49:40 +03:00
const { todos, actions } = this.props;
2015-07-14 22:46:44 +03:00
return (
<div>
<Header addTodo={actions.addTodo} />
<MainSection todos={todos} actions={actions} />
</div>
);
}
}
2015-08-07 19:49:40 +03:00
function mapState(state) {
return {
todos: state.todos
};
}
function mapDispatch(dispatch) {
return {
actions: bindActionCreators(TodoActions, dispatch)
};
}
export default connect(mapState, mapDispatch)(TodoApp);