I hope you are well.
I need some help in react, I am relatively new in react. The problem is the following.
I have a card made with materialize and in the content I have 4 checkboxes. I want that when a checkbox is marked, it is added to a numerical quantity of an object that I have, in this case a car.
Here is the code of my component.
import React ,{Component} from 'react';
class CheckBox extends Component{
constructor(props){
super(props);
this.state={
Puertas:'',
Neon:'',
Ventanas:'',
Neumaticos:'',
}
this.handleCheckBox = this.handleCheckBox.bind(this);
}
handleCheckBox(e){
if(e === true){
console.log('true');
}else{
console.log('false')
}
}
render(){
return(
<div className="container">
<p>
<label>
<input type="checkbox" onChange={(e)=>this.handleCheckBox(e.target.value) } />
<span>Puertas</span>
</label>
</p>
<p>
<label>
<input type="checkbox" />
<span>Ventanas</span>
</label>
</p>
<p>
<label>
<input type="checkbox" />
<span>Neon</span>
</label>
</p>
<p>
<label>
<input type="checkbox" />
<span>Neumaticos</span>
</label>
</p>
</div>
)
}
}
export default CheckBox
Here I am trying to print on the console when it is active or not.