React State Example
var Checkbox = React.createClass({
getInitialState(){
return {checked: false}
},
handleCheck(){
this.setState({checked: !this.state.checked})
},
render() {
var msg;
if (this.state.checked) {
msg = "checked"
}
else {
msg = "unchecked"
}
return (
<div>
<input type="checkbox" onChange={this.handleCheck}/>
<p>This box is {msg}</p>
</div>
)
}
})
ReactDOM.render(<Checkbox/>, document.getElementById('react-container'))