Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
ReactJS: React-Select to call api and filter result

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.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda