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

65
Views
I need one link to have different text depending on the current page

I have a website with two pages. When clicking on the nav link, I need the page and the nav link name to change. I tried this:

const [isClicked, setIsClicked] = useState(false);

const ClickHandler = () => {
    setIsClicked(!isClicked);
}

<NavLink to={isClicked ? '/' : '/profile'} onClick={ClickHandler}><NavPage>{isClicked ? 'Home': 'Profile'}</NavPage></NavLink>

but this showed me an error where when going to profile page. The link name and the actual link do not change, only the page changes, it has to be clicked again for everything to be ok.

Another problem when refreshing in the profile page the link name becomes profile again, I want it to be home.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To keep the link between session, the value must be stored in localStorage or cookies, because now it depends on the state.

Maybe it'd be better to pass the target link via props?

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!