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

102
Vistas
React Link to current URL does not reload page

I have an image logo on my ReactJS website which has a link to load the current page URL. I can see that the URL is correct (when I hover on the image, the correct URL is displayed at the bottom left corner of the browser), but when I click on the image the page does not reload (it does essentially nothing, not even a re-render).

<Link to={`${window.location.pathname}`}>
     <img className="img-fluid" src={Logo} alt="Alt_Text" />
</Link>

Is there any way to reload the page without using an onClick handler in the Link?

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

0

If you want to force the window to reload, you can try to use window.location.reload() in any event you wanna trigger.

React-Router-Dom will only redirect your url history only if it detects any change, and it will not reload page at all because React is typically used to build Single-Page-Application (SPA). Therefore, what you are asking is contradicting to the principle of React and React-Router-Dom.

about 4 years ago · Juan Pablo Isaza Denunciar

0

try these:

user Link:

 <Link to={`${window.location.pathname}`} onClick={()=>{window.location.reload()}}> <img className="img-fluid" src={Logo} alt="Alt_Text /></Link>

Or use a tag:

 <a href={`${window.location.pathname}`}><img className="img-fluid" src={Logo} alt="Alt_Text /></a> 
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