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

63
Vistas
React router dom NavLink only works when refresh no when click the nav item

A react-router-dom NavLink only works after refresh not when clicking the nav item.

<NavLink
   to="/test"
   activeClassName="active">
   test
</NavLink>

I don't get any errors on the page. When I clicked on the NavLink it updated my URL but did not apply the active class, I have to refresh the page to get the active class on the NavLink. Using v5

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

0

First you have to import NavLink.then you can directly set activeStyle to the styles you want.

import { NavLink } from 'react-router-dom';
<NavLink to="/test" activeClassName="active">
 Test
</NavLink>

Style your class in the css by the property active:

.active{
  color:#3895d3;
 }
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