Business
Jobs
  • About Us
  • Solutions
    • Candidates
      We find and qualify the candidate in 48h.
    • Assessments
      500+ technical and psychological assessments, plus anti-fraud system.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Pay in 15+ LATAM countries without setting up a local entity.
  • Pricing
  • Jobs

0

329
Views
Rutas modales en react-router

Traté de implementar el enrutador modal como en el ejemplo del enrutador de reacción , pero funciona cuando se usa con Link , pero no funciona cuando trato de usar history.push . Estoy tratando de implementar modal multinivel con navegación programática. Compruebe el bombardeo de la pila

 // This works <Link to={{ pathname: `/img/${id}`, state: { background: location } }} > <Thumbnail color={color} /> <p>{title}</p> </Link> // This doesn't <a href="#" onClick={ () => history.push({ pathname: `/img/${id}`, state: { background: location } }) }> <Thumbnail color={color} /> <p>{title}</p> </div> // My Router <div> <Switch location={background || location}> <Route path="/" exact component={Home} /> <Route path="/contacts" exact component={Contacts} /> </Switch> {background && <Route path="/contact/:name" children={<Modal />} />} </div>

¿Cómo soluciono esto para que funcione sin la etiqueta de Link ? ¿Cuál es el error en el código utilizado?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que esto podría resolverse agregando event.preventDefault(). Porque cuando hace clic en el enlace, se vuelve a cargar toda la página y nunca se ejecuta history.push()

 <a href="#" onClick={ (e) => { e.preventDefault() history.push({ pathname: `/img/${id}`, state: { background: location } }}) }>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

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