I'm using a material-ui checkbox that uses state. When I click to select an option, it selects all, but I would like him to select only the one that was clicked.
code:
export default function Categorys() {
const [state, setState] = React.useState({
checkedG: true
});
const handleChange = event => {
setState({ ...state, [event.target.name]: event.target.checked });
};
return (
<>
{categorys.map(category => (
<FormControlLabel
key={category.id}
control={
<GreenCheckbox
checked={state.checkedG}
onChange={handleChange}
name="checkedG"
key={category.id}
/>
}
label={category.name}
/>
))}
</>
);
}
