Last active
December 8, 2016 15:03
-
-
Save jide/52382f45363d16aa5ccfd13dbdb0e165 to your computer and use it in GitHub Desktop.
This file contains 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 { render } from 'react-dom' | |
import { createStore } from 'redux' | |
import { Provider } from 'react-redux' | |
import { createElement, wire } from 'react-redux-wire' | |
import reducer from './reducers' | |
import { toggleTodo, addTodo, setVisibilityFilter } from './actions' | |
import App from './components/App' | |
import TodoList from './components/TodoList' | |
import AddTodo from './components/AddTodo' | |
import Link from './components/Link' | |
const store = createStore(reducer); | |
const getVisibleTodos = //... | |
TodoList.mapStateToProps = state => | |
({ todos: getVisibleTodos(state.todos, state.visibilityFilter) }) | |
TodoList.mapDispatchToProps = dispatch => | |
({ onTodoClick: id => dispatch(toggleTodo(id)) }) | |
AddTodo.mapDispatchToProps = dispatch => | |
({ addTodo: (...args) => dispatch(addTodo(...args)) }) | |
Link.mapStateToProps = (state, ownProps) => | |
({ active: ownProps.filter === state.visibilityFilter }) | |
Link.mapDispatchToProps = (dispatch, ownProps) => | |
({ onClick: () => dispatch(setVisibilityFilter(ownProps.filter)) }) | |
wire(TodoList, AddTodo, Link) | |
render( | |
<Provider store={ store }> | |
<App/> | |
</Provider>, | |
document.getElementById('root') | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment