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

95
Visualizações
React-Select is not showing selected options on the searchbar

When I try and select an option from the dropdown it doesn't show on the searchbar if I add an if statement inside the onChange handler function, when I remove "if statement" the selected options get displayed on the bar.

                <Select
                  isMulti
                  name="colors"
                  options={cat.subs.map((sub) => {
                    return { value: sub, label: sub.name };
                  })}
                  className="basic-multi-select"
                  classNamePrefix="select"
                  onChange={handleChange}
                />

And this is the change handler function, it works perfectly, but the selected option are not displayed on the searchbar

const handleChange = (newValue, actionMeta) => {
  if (actionMeta.action === "remove-value") {
    removeSubCategory(actionMeta.removedValue.value);
  } else if (actionMeta.action === "select-option") {
    addSubCategory(actionMeta.option.value);
  }
};
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If the removeSubCategory function removes the value from your data, it won't be available to select again, will it? Please can you provide more context on how those functions modify the data that provides your options.

about 4 years ago · Juan Pablo Isaza Relatório
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