Skip to content

Instantly share code, notes, and snippets.

@StoneCypher
Last active January 3, 2018 18:15
Show Gist options
  • Select an option

  • Save StoneCypher/96e2c147694bddb91c98 to your computer and use it in GitHub Desktop.

Select an option

Save StoneCypher/96e2c147694bddb91c98 to your computer and use it in GitHub Desktop.
var App = function() {
var counter = 0,
inc = () => { ++counter; repaint() },
dec = () => { --counter; repaint() },
hooks = {inc: inc, dec: dec};
return {
inc: inc,
dec: dec,
value: () => counter,
repaint: () => React.render(document.body, <Spinner data={counter} hooks={hooks}/>)
};
}
var Spinner = React.createClass({
render: function() {
return <div>
{this.props.data}
<button value="^" onclick={this.props.inc}/>
<button value="v" onclick={this.props.dec}/>
</div>;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment