import * as React from 'react'; import TextField from '@mui/material/TextField'; import Chip from '@mui/material/Chip'; import Autocomplete from '@mui/material/Autocomplete'; export default function GameAdder(props) { const [value, setValue] = React.useState([]); const emptyUuid = "00000000-0000-0000-0000-000000000000"; return ( option.name} freeSolo selectOnFocus renderTags={(value, getTagProps) => value.map((option, index) => ( )) } renderInput={(params) => ( )} onChange={(event, newValue) => { newValue = newValue.map(option => { if (typeof option === 'string') { var match = props.games.find(g => g.name.toLowerCase() === option.toLowerCase()); if(match !== undefined) { return match } else { return {id: emptyUuid, name: option}; } } else { return option; } }); newValue = newValue.filter((value, index, self) => index === self.findIndex((t) => ( t.id === value.id && t.name === value.name )) ); setValue(newValue); props.onChange(newValue); }} /> ); }