Skip to content

Instantly share code, notes, and snippets.

@ProTip
Created August 31, 2017 02:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ProTip/2c9add0e346c562cf55069590e6cfb36 to your computer and use it in GitHub Desktop.
Save ProTip/2c9add0e346c562cf55069590e6cfb36 to your computer and use it in GitHub Desktop.
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