March 2019
Intermediate to advanced
534 pages
14h 52m
English
Let's take a closer look at the RadioGroup component in this example:
const RadioGroup = ({ value, options, name, label, onChange }) => ( <FormControl component="fieldset"> <FormLabel component="legend">{label}</FormLabel> <MaterialRadioGroup name={name} value={value} onChange={onChange}> {options.map((option, index) => ( <FormControlLabel key={index} control={<Radio />} value={option.value} label={option.label} /> ))} </MaterialRadioGroup> </FormControl>);
The options property should have an array value, which is then mapped to the FormControlLabel components. The control property uses the Radio component to render each radio control. Unlike checkbox groups, the onChange property is on the MaterialRadioGroup component instead ...
Read now
Unlock full access