Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
Desencadenar evento de niño a padre, {niños}

Quiero activar un evento modal desde el componente de niños. Por lo general, paso el estado en forma de <Children handleOpen={HandleOpen} /> . Si se presiona el botón en el componente secundario, el evento dentro del elemento principal debe activarse y mostrar el texto de los elementos secundarios. ¿Cómo puedo darme cuenta si {children} está en uso?

aplicación.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> ); }

Contenedor de diseño/Principal/Básico

 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> ); };

niños1 y niños2

 const children1 = ( { handleOpen }) => { return ( <div> <button onClick={handleOpen} data={xxx}>Open Modal with xxx Text</button> </div> ); };
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!