lundi 25 juillet 2022

Checkboxes with react and MUI

I have 2 checkboxes, at the moment when one is selected both of when select. I want to be able to select one or both or none. I am not sure why the are both being selected at the same time.

These are my checkboxes

 ``` <FormControlLabel
      control={<Checkbox checked={checked} onChange={handleChange} color="primary"    />}
      label="Domain DNC file (Check if no list is required)"
    /> 

    <FormControlLabel
      control={<Checkbox checked={checked} onChange={handleChange} color="primary"    />}
      label="Email DNC file (Check if no list is required)"
    /> 


This is my onChange:

         const handleChange = (event) => {
          setChecked(event.target.checked);
         };


And this is my state:

    const [checked, setChecked] = React.useState(true);



Aucun commentaire:

Enregistrer un commentaire