Skip to content

Instantly share code, notes, and snippets.

@ir4y
Last active March 4, 2016 08:48
Show Gist options
  • Save ir4y/c8610b78b43856764b79 to your computer and use it in GitHub Desktop.
Save ir4y/c8610b78b43856764b79 to your computer and use it in GitHub Desktop.
counter.js
import React from 'react';
import SchemaBranchMixin from 'baobab-react-schemabranchmixin';
const Counter = React.createClass({
displayName: 'Counter',
mixins: [SchemaBranchMixin, ],
schema: {
value: 0,
},
inc(){
this.cursors.value.apply(v => v+1);
},
dec(){
this.cursors.value.apply(v => v-1);
},
render(){
return <div>
<button onClick={this.inc}>+</button>
{this.state.value}
<button onClick={this.dec}>-</button>
</div>
},
});
export default React.createClass({
displayName: 'CounterList',
mixins: [SchemaBranchMixin, ],
schema: {
counters: [],
},
render(){
return <div>
<h1>Counters</h1>
</div>
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment