I have a very simple problem and I'm stuck:
- I have a simple MUI react switch with state tracker
- It doesn't work first time, but it works all subsequent times... EDIT: specifically the state is not updated the first time, the lgos show false, false, true, false, true instead of false, true, false, true etc
const [checked, setChecked] = useState(false);
const handleChange = () => {
setChecked(!checked);
if(image.file != null){
displayImage(image.file);
}
};
<FormGroup>
<FormControlLabel control={<Switch checked={checked} onChange={handleChange} color="secondary"/>} label="Center Image" />
</FormGroup>