Skip to content

Instantly share code, notes, and snippets.

@roger-hamilton
Created August 25, 2016 13:53
Show Gist options
  • Save roger-hamilton/9cce3d6aac58c558ec1e4a812ec147cb to your computer and use it in GitHub Desktop.
Save roger-hamilton/9cce3d6aac58c558ec1e4a812ec147cb to your computer and use it in GitHub Desktop.
untitled
import React from 'react';
import { observer } from 'mobx-react';
import { test } from './stores';
const inc = () => test.val++;
const dec = () => test.val--;
const reset = () => test.reset();
const App = observer(() => (
<div>
<h1>Test Val {test.val}</h1>
<button onClick={inc}>+</button>
<button onClick={dec}>-</button>
<button onClick={reset}>Reset</button>
</div>
));
export default App;
import React from 'react';
import { render } from 'react-dom';
import DevTools from 'mobx-react-devtools';
import App from './App'
render((
<div>
<DevTools />
<App />
</div>
),
document.getElementById('root')
);
import { observable } from 'mobx';
export const test = observable({
val: 0,
reset() {
this.val = 0;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment