-
-
Save samsch/b4f2966c9147d89210d51eb90d2687e5 to your computer and use it in GitHub Desktop.
StoneCypher's external state example, re-written for React latest (15.x)
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
let counter = 0; | |
const repaint = () => React.render(<Spinner data={counter}/>, document.body); | |
const inc = () => { counter += 1, repaint() }; | |
const dec = () => { counter -= 1, repaint() }; | |
const Spinner = ({ counter }) => ( | |
<div> | |
{counter} | |
<button value="^" onclick={inc}/> | |
<button value="v" onclick={dec}/> | |
</div> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment