How to do it...

Let's say that, instead of creating a component that abstracts a group of Checkbox components, you you want want to do the same thing with the Switch components. Here's the code:

import React, { Fragment, 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 Switch from '@material-ui/core/Switch';const SwitchGroup = ({ values, label, onChange }) => (  <FormControl component="fieldset">    <FormLabel component="legend">{label}</FormLabel>    <FormGroup> {values.map((value, ...

Get React Material-UI Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.