Next.js Discord

Discord Forum

Empty string passed to getElementById().

Unanswered
Swedish Lapphund posted this in #help-forum
Open in Discord
Avatar
Swedish LapphundOP
Whenever I do the following

8 Replies

Avatar
Swedish LapphundOP
Image
I am not sure why it does that though...
<Autocomplete
  id="disabilities"
  fullWidth
  multiple
  options={getDisabilitiesOptions()}
  value={profileDisabilities}
  onChange={(_, selectedDisabilities) => {
    setProfileDisabilities(selectedDisabilities);
  }}
  disableCloseOnSelect
  renderTags={(tagValue, getTagProps) => {
    return tagValue.map((option, index) => (
      <Chip {...getTagProps({ index })} key={option} label={option} />
    ))
  }}
  renderInput={(params) => (
    <TextField
      {...params}
      label="Disabilities" 
      placeholder="Select Disabilities"
    />
  )}
/>
when I do it with a value:
Image
notice how it goes from panel to main, its like a bool is being inverted lol
getDisabilitiesOptions() returns a string[]
Avatar
Hassib
Hi, the warning happens because the getDisabilitiesOptions() returns an array of objects containing key and value, it's okay. The problem lies in the onChange function; you should set the key of the disability not the whole object.