-
-
Save dashed/707664be1319bb222c7c to your computer and use it in GitHub Desktop.
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
var structure = immstruct({turtles: []}); | |
var TurtlesComponent = React.createClass({ | |
componentWillMount: function() { | |
this.setState({turtlesCursor: structure.cursor()} | |
structure.on('swap', () => | |
this.setState({turtlesCursor: structure.cursor()})); | |
}, | |
onAddButtonClick: function(e) { | |
this.state.turtlesCursor.updateIn('turtles', (turtles) => | |
turtles.push(e.target.turtle) | |
); | |
}, | |
renderTurtleCount: function() { | |
return <div>{this.state.turtlesCursor.deref().size}</div>; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment