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

134
Vistas
React JS : All option in Autocomplete

I have below state -

const[values,setValues]=useState<IValue[]>([]);

const[value,setValue]=useState<IValue|null>();

<Autocomplete
 options={values}
 value={value}
 id="value_id"
 getOptionLabel={(option:IValue)=>`(${option.Id}) ${option.Name}`}
 renderInput={(param)=> <TextField {...param}/>}
/>

export interface IValue
{
 Id:string;
 Name : string;
}

useEffect(()=>{
//api call

setValues([...res.data]);
},[])

Autocomplete takes the value from Api call and sets the list. I want to add "All" before the autocomplete list , default selected.

I tried with -

const[value,setValue]=useState<IValue|null>({Id="",Name="All"});

By this way , All appears in the list , but after making any other selection from list , it disappears.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

have you tried:

setValues([{Id:"", Name:"All"},...res.data]);
about 4 years ago · Juan Pablo Isaza Denunciar
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