Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

72
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda