Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

280
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda