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

279
Views
React-Select: Setting selected option when state changes from outside source (not by selecting a new option)

Hi all so basically I am using the react-select library to help streamline some select components I am using in my app. I am using state to keep track of the changes between the values. I am taking this value as well as others and submitting a form to firebase. The issue I am having is when I attempt to load and edit the data. I am currently loading in the field data from firebase and setting the current state to so that the form components display the values from firebase and can be edited. When doing this the data load into the text fields just fine, but the select component does not. I can see the value being passed but the select component doesn't recognize that value should be loaded as the currently selected option. Has anyone had a similar issue?

  const [make, setMake] = useState("");
  const carMakeOptions = [value: "ford", label: "Ford"
                          value: "toyota", label: "Toyota" ...........]
                                                      

 <Select defaultValue={make} defaultInputValue={make} options={carMakeOptions} onChange={(e) => {setMake(e.value)}}> 

Loading in data from firebase and resetting state here:

  setMake(carDocSnap.data().make);
about 4 years ago · Juan Pablo Isaza
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!