March 2019
Intermediate to advanced
534 pages
14h 52m
English
Let's create an abstraction for groups of checkbox options. Here's the code for a CheckboxGroup component:
import React, { useState } from 'react';import FormLabel from '@material-ui/core/FormLabel';import FormControl from '@material-ui/core/FormControl';import FormGroup from '@material-ui/core/FormGroup';import FormControlLabel from '@material-ui/core/FormControlLabel';import FormHelperText from '@material-ui/core/FormHelperText';import Checkbox from '@material-ui/core/Checkbox';const CheckboxGroup = ({ values, label, onChange }) => ( <FormControl component="fieldset"> <FormLabel component="legend">{label}</FormLabel> <FormGroup> {values.map((value, index) => ( <FormControlLabel key={index} control={ <Checkbox checked={value.checked} ...Read now
Unlock full access