79275690

Date: 2024-12-12 15:34:50
Score: 2
Natty:
Report link

A solution has been found, so I want to share it for others so then don't have to send as much time searching for a solution as I did.

This is the example from the MUI website. This will display a comma-separated list using the value of your MenuItem, in the example above it would be the option.id as designated value={option.id}

renderValue={(selected) => selected.join(', ')} 

I needed to pass the ID back as a my value, rather than the name, so to be able to use something other than what is designated in the value prop, it required creating a filter and mapping through the options array which populate the dropdown to fetch the name.

This will allow you to use the option.name rather the value of option.id

renderValue={(selected) => {
    const selectedOption = options.filter((option) => 
    selected.includes(option.id)).map((option) => option.name);
    return selectedOption.join(', '); }
}
```
Reasons:
  • Blacklisted phrase (0.5): I need
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Mtullis