Skip to content

Instantly share code, notes, and snippets.

@otbe
Last active April 26, 2016 17:24
Show Gist options
  • Select an option

  • Save otbe/52a5ba1de9264dc1d58c2f21fee338ca to your computer and use it in GitHub Desktop.

Select an option

Save otbe/52a5ba1de9264dc1d58c2f21fee338ca to your computer and use it in GitHub Desktop.
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