I'm creating a search box where you can write some letters and the api should gives back a list filtered. Now my problem is that this list is empty (but the value that should be display is found)
<AvGroup>
<Label id="comCodLabel" for="sce-persona-comCod">
<Trans i18nKey="sce_persona.comCod">{'sce_persona.comCod'}</Trans> {'*'}
</Label>
<Async
options={listaValoriTrovati}
value={comCod}
loadOptions={getComuniNome.bind(this)}
onChange={onChangeComuni}
// getOptionLabel={options => options['label']}
// getOptionValue={options => options['value']}
/>
</AvGroup>
const [listaValoriTrovati, setListaValoriTrovati] = useState([])
const getComuniNome = (searchTerm) => {
console.log("searchTerm ", searchTerm)
return axios.get(`${apiComuni}?comDes.contains=${searchTerm}`)
.then(res => {
console.log("res ", res.data)
setListaValoriTrovati(res.data.map(val => { return ({ value: val.comCod, label: val.comDes }) }))
})
}
console.log("listaValoriTrovati ", listaValoriTrovati)
this listaValoriTrovati console.log me an array of object [{value: 'value', label: 'label'}]
But the list displayed is empty and doesn't show the label.
In your opinion how can I do?
Thank you.