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

193
Vistas
Passing useState value to React input component

I have created a React component that allows the user to filter a list by typing into an input, I have simplified the component into the below:

const value = filteredOptions
   .filter((option) => option.selected)
   .map((option) => option.label)
   .join(",");

const [input, setInput] = useState(value);

const handleSearch = (e) => {
   e.preventDefault();
   setInput(e.target.value);
};

return (
<InputSearch 
   value={input}
   onChange={handleSearch}
/>
<SelectOption
   key={option.code}
   option={option}
   onClick={onValueChange}
/>

);

value is null by default (and is populated with a string value when selected) - this works. what I would like to do however is feed the value into my input state so that the input state can be updated either by typing into the input (which works currently) or by selecting a value.

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