Created
August 31, 2017 02:13
-
-
Save ProTip/2c9add0e346c562cf55069590e6cfb36 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 React, {Component} from 'react'; | |
import ReactDOM from 'react-dom'; | |
import {observer} from "mobx-react"; | |
@observer | |
class TodoListView extends Component { | |
render() { | |
return <div> | |
<ul> | |
{this.props.todoList.todos.map(todo => | |
<TodoView todo={todo} key={todo.id} /> | |
)} | |
</ul> | |
Tasks left: {this.props.todoList.unfinishedTodoCount} | |
</div> | |
} | |
} | |
const TodoView = observer(({todo}) => | |
<li> | |
<input | |
type="checkbox" | |
checked={todo.finished} | |
onClick={() => todo.finished = !todo.finished} | |
/>{todo.title} | |
</li> | |
) | |
const store = new TodoList(); | |
ReactDOM.render(<TodoListView todoList={store} />, document.getElementById('mount')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment