Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

71
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

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