This Gist was automatically created by Carbide, a free online programming environment.
Created
August 25, 2016 13:53
-
-
Save roger-hamilton/9cce3d6aac58c558ec1e4a812ec147cb to your computer and use it in GitHub Desktop.
untitled
This file contains 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 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; |
This file contains 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 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') | |
); |
This file contains 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 { 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