React Base Fiddle (JSX)
Starting point for creating JSFiddles with React.
HTML
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
Babel + JSX
class CheckBox extends React.Component{
constructor(props){
super(props);
this.state = {checked: false};
}
changeState(){
this.setState({
checked : !this.state.checked
});
}
render(){
var msg;
msg = this.state.checked ? 'Sim' : 'Não';
return(
<div>
<input type="checkbox" defaultChecked={this.state.checked} onChange={this.changeState.bind(this)}/>
<p>{msg}</p>
</div>
)
}
}
ReactDOM.render(
<CheckBox/>,
document.getElementById('container')
);