mardi 11 août 2020

Keeping the button disabled, if no checkboxes are selected in reactjs

I have used mui checkboxes by mapping them the following way :

 <FormControl component="fieldset">
                                <FormGroup aria-label="position" column >
                                    {sortedData.map((obj) => {
                                        return (
                                            <FormControlLabel
                                                value="type"
                                                control={<Checkbox color="primary"/>}
                                                label={obj}
                                                onChange={handleTypeCheckboxChange}
                                                labelPlacement="end"
                                            />
                                        );
                                    })}
                                </FormGroup>
                            </FormControl>

This is how my checkboxes look like:

enter image description here

Now I need to set my Next button disabled, unless the user has selected one checkbox or more. Also , I wanna store the values of the selected checkboxes in an array so that I can access it later. Can anyone help me out on how this should work? Thanks!




Aucun commentaire:

Enregistrer un commentaire