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

155
Vistas
Trigger event from child to parent, {children}

I want to trigger a modal event from the children component. Usally I pass the state in form of <Children handleOpen={HandleOpen} />. If the button get pressed in the children component, the event inside the parent should be triggerd and show the text from the children. How can I realize that if {children} is in use?

app.js

const App = () => {
  return (
      <Router>
        <div>
          <Switch>
          <PrivateRoute exact path="/children1" component={children1} layout={basic} />
          <PrivateRoute exact path="/children2" component={children2} layout={basic} />
          </Switch>
        </div>
      </Router>
  );
}

Layout Wrapper/Parent/Basic

const Basic = ({children}) => {
    //Modal
    const [open, setOpen] = React.useState(false);
    const handleOpen = () => setOpen(true);
    const handleClose = () => setOpen(false);

    return (
      <div className="App">
        //Insert Children Component
        {children}

        //Show this Modal when called from children/with sent data
        <Modal open={open} onClose={handleClose}>
         <Box>
          data xxx from child
         </Box>
        </Modal>
      </div>
    );
  };

children1 & children2

const children1 = ( { handleOpen }) => {
    return (
      <div>
        <button onClick={handleOpen} data={xxx}>Open Modal with xxx Text</button>
      </div>
    );
  };
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