This is my initial state
class RoomAmmenitiesForm extends Form {
state = {
data: {
free_toiletries: false,
blackout_drapes: false,
safe_deposit_box: false,
lcd_tv: false,
free_wifi: false,
pay_tv: false,
}}
This is my checkbox handler function
toggleCheckbox = (e) => {
const AmmenityBoxName = e.target.name;
this.setState((state) => ({
data: {
...state.data,
[AmmenityBoxName]: !state.data[AmmenityBoxName],
},
}));
};
How do i add a function to handle checking and unchecking all checkboxes? Kindly assist
Aucun commentaire:
Enregistrer un commentaire