I am using Material UI Multiple Select based on documentation example. I need to save id of the selected option and show name, so I render object. When I used example from documentation with placeholder, i see ids instead names of selected. See: https://codesandbox.io/s/kxz5yqmrzv?from-embed
const names = [
{ id: "a", name: "Oliver Hansen" },
{ id: "b", name: "Van Henry" },
{ id: "c", name: "April Tucker" },
{ id: "d", name: "Ralph Hubbard" },
{ id: "e", name: "Omar Alexander" },
{ id: "f", name: "Carlos Abbott" },
{ id: "g", name: "Miriam Wagner" },
{ id: "h", name: "Bradley Wilkerson" },
{ id: "i", name: "Virginia Andrews" },
{ id: "j", name: "Kelly Snyder" }
];
<Select
multiple
displayEmpty
value={this.state.name}
onChange={this.handleChange}
input={<Input id="select-multiple-placeholder" />}
renderValue={selected => {
if (selected.length === 0) {
return <em>Placeholder</em>;
}
return selected.join(", ");
}}
MenuProps={MenuProps}
>
<MenuItem disabled value="">
<em>Placeholder</em>
</MenuItem>
{names.map(name => (
<MenuItem
key={name.id}
value={name.id}
// style={getStyles(name, this)}
>
{name.name}
</MenuItem>
))}
</Select>