I have a working material ui auto component that has the following code:
<Autocomplete
multiple
options={props.cats}
defaultValue={editRequest?([props.cats[props.post.category]]):undefined}
limitTags={2}
This works when props.post.category has just one value in props.post.category.
When there are two values such as 34,36 coming in for props.post.category, it breaks the page with errors.
In a normal function, I would use .map to loop through the array. This is inside a defaultValue so I cant figure out how to assign two default values which are basically
props.cats[34] and props.cats[36]
In other words, how can a string separated by commas be converted to individual arrays
input=> 34,35 (stored in props.category)
array=> [props.cats[34], props.cats[35]]