Last active
April 26, 2016 17:24
-
-
Save otbe/52a5ba1de9264dc1d58c2f21fee338ca 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 } from 'react'; | |
| import { observer } from 'mobx-react/index'; | |
| import { observable } from 'mobx/lib/mobx'; | |
| @observer | |
| export class Todo extends Component<{todoId: string}, {}> { | |
| @observable | |
| private todo: Todo; | |
| async componentWillMount () { | |
| const { todoId } = this.props; | |
| this.todo = await fetch(`http://.../${todoId}`); | |
| } | |
| render() { | |
| if(this.todo != null) { | |
| return ( | |
| <p>{this.todo.name} <button onClick={() => this.todo.active = true}>activate</button></p> | |
| ); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment