March 2019
Intermediate to advanced
534 pages
14h 52m
English
Let's start by taking a look at how the Select component is rendered:
<Select multiple value={selected} onChange={onChange} input={<Input id="multi" />}> {options.map(option => ( <MenuItem key={option.id} value={option.id}> {option.label} </MenuItem> ))}</Select>
The options array values are mapped to MenuItem components, just like any other Select. The multiple property tells the component to allow the user to make multiple selections. The selected state of the SelectingMultipleItems component is an array, which holds the selected values. This array is populated by the onChange handler:
const onChange = e => { setSelected(e.target.value);};
Because the multiple property was used, e.target.value is an array of selected values—you ...
Read now
Unlock full access