console
const { observable } = mobx;
const { observer } = mobxReact;
const { Component } = React;
const appState = observable({
count: 0,
});
appState.increment = function() {
this.count ++;
};
appState.decrement = function() {
this.count --;
};
@observer
class Count extends Component {
render() {
return (<div>
Counter: { appState.count } <br />
<button onClick={this.handleInc}> + </button>
<button onClick={this.handleDec}> - </button>
</div>);
}
handleInc() {
appState.increment();
}
handleDec() {
appState.decrement();
}
}
React.render(<Count />, document.getElementById('root'));
<body>
<div id="root"></div>
</body>