I\'m having trouble to update the checkbox state after it\'s assigned with default value checked="checked" in React.
var rCheck = React
I tried to accomplish this using Class component: you can view the message for the same
.....
class Checkbox extends React.Component{
constructor(props){
super(props)
this.state={
checked:true
}
this.handleCheck=this.handleCheck.bind(this)
}
handleCheck(){
this.setState({
checked:!this.state.checked
})
}
render(){
var msg=" "
if(this.state.checked){
msg="checked!"
}else{
msg="not checked!"
}
return(
this box is {msg}
)
}
}