Before this is marked as duplicate I have searched and none of the answers seems to work for me.
My checkbox isn't working when changed, clicked, checked it whatever.
This is my component
class Checkbox extends React.Component{
constructor(props) {
super(props);
this.state = {checked: false}
this.handleCheck = this.handleCheck.bind(this);
}
this.handleCheck(e) {
e.preventDefault();
this.setState({
checked: e.target.checked
})
}
render() {
return (
<input type="checkbox" checked={this.state.checked} onChange={this.handleChecked}
);
}
}
Any reason why it shouldn't work?
this.handleCheckedin theonChange, but your method is namedhandleCheck