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

287
Vistas
Why is React-router link not working on onClick function
 <Link to="/final-preview">
            <button  onClick={handleSubmit}>
              Final Preview
            </button>
 </Link>

So before the onClick function the Link was working perfectly but after it's not. I'd be really grateful if someone knows some specificity about router link :)

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You could potentially try useNavigate as a solution instead as

import { useNavigate } from "react-router-dom";

function ThisPage() {
  let navigate = useNavigate();

  const leavePage = () => {
    navigate("/final-preview");
  }
  
  return (
    <div>
      <button onClick = {leavePage}/>
    </div>
  )
}

export default ThisPage;

In the leave page method, you can handle submitting the preview, before navigating to the next link.

Hope this helps.

about 4 years ago · Santiago Trujillo Denunciar

0

Here is example

First Import React Router

import {
  Link as RouterLink,
  Route,
  Routes,
} from "react-router-dom";

Add code

<Link component={RouterLink} to="/final-preview">
      <button  onClick={handleSubmit}>
       Final Preview
       </button>
 </Link>
about 4 years ago · Santiago Trujillo 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