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

96
Vistas
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 Respuestas
Responde la pregunta

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 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