I am new in react. following a tutorial, where they are introducing state to find out wheather checkbox is checked or not. But i wanted to do that in this style:
<script type="text/babel">
var Checkbox = React.createClass({
change: function(){
var msg;
var val= document.getElementById('check').checked;
if(val==true){
msg = 'checked';
}else{
msg = 'Not checked';
}
},
render: function(){
return(<div>
<input onChange={this.change} id="check" type="Checkbox" />
<p>Checkbox is {this.msg}.</p>
</div>);
}
});
ReactDOM.render(<Checkbox/>, document.getElementById('container'));
</script>
so, the problem is i cant pass the variable "msg" into render function.
statewithsetStatefunction.. Also,createClassis deprecated.