Handle change on Autocomplete Component from material ui

前端 未结 5 873
無奈伤痛
無奈伤痛 2021-02-01 17:36

I want to use Autocomplete component for input tags. I\'m trying to get the tags and save them on a state so I can later save them on the database. I\'m using funct

5条回答
  •  星月不相逢
    2021-02-01 18:30

    @Dworo

    For anyone that has a problem with displaying a selected item from dropdown in Input field.

    I found a workaround. Basically you have to bind a inputValue at onChage for both Autocomplete and TextField , bad Material UI.

    const [input, setInput] = useState('');
    
     option}
      inputValue={input}
      onChange={(e,v) => setInput(v)}
      style={{ width: 300 }}
      renderInput={(params) => (
         setInput(target.value)} variant="outlined" fullWidth />
      )}
    />
    

提交回复
热议问题