0
votes

I want to return a single value as an array with one value rather than a string but when I try to do that in renderValue it still returns a string

<Select
                  id="demo-mutiple-checkbox"
                  value={formData.sector}
                  onOpen={(e) => setAnchorEl(e.currentTarget)}
                  onChange={(e) => handleFormChange("sector", e)}
                  input={<Input placeholder="Sector" />}
                  renderValue={(selected) => {
                    return (selected as string[]);
                  }}
                  MenuProps={{
                    anchorEl: anchorEl,
                    PaperProps: {
                      style: {
                        maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
                        marginTop: 4,
                      },
                    },
                    MenuListProps: {
                      style: {
                        padding: 0,
                      },
                    },
                    anchorOrigin: {
                      vertical: "bottom",
                      horizontal: "left",
                    },
                    getContentAnchorEl: null,
                  }}
                >
1
What do you mean but "return" ? you want the value after selection to be [selected] ? Could you also post the full code?dglozano

1 Answers

0
votes

How about

renderValue={(selected) => {
     return ([selected]);
}}