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

250
Vistas
Call a component's onChange method inside another one in React

There is a Selector component of this form:

<Selector
  initialSelectedOption={data[0].type}
  onChange={(val) => changeValue(val.name)}
  options={valueOptions}
/>;

when the user selects a value from the dropdown, onChange is called and the value is updated in the selector.

I want to reset the value to the original one once the user has clicked cancel:

 <Button onClick={handleCancel} />
...

  const handleCancel = () => {
    changeValue(data[0].type);
  };

However, something is wrong here as it is not called.

Is it a way to call the Selector's onChange method from handleCancel?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

We need a bit more context to know for sure, but in general, you should define onChange in a parent component and pass it as a prop to both the selector component and the component that handles the cancel.

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