Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
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 answers
Answer question

0

have you tried:

setValues([{Id:"", Name:"All"},...res.data]);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!