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

188
Views
React, i18n, changing location after reload page

I use i18n to translate page. Page have 3 language, polish, german and english. German is default language. It works, but when I change language to german, and then I reload page location is changing to poland. Generally I know why it's happaning. German is default language, so when I change language to german, nothing is added to url. Then after reload page when my browser localization is poland, language in page is changing to polish.

<div className="language">
    <span>
        <link href="{router.asPath}" locale="de"
            <a onClick="{handleClick}"><img width="30px" className={locale == 'de' ? 'selected' : ''} src="/images/flags/flaga-niemiec.png"/></a>
        />
    </span>
    <span>
        <link href="{router.asPath}" locale="pl"
            <a onClick="{handleClick}"><img width="30px" className={locale== 'pl' ? 'selected' : ''} src="/images/flags/flaga_polski.png"/></a>
        />
    </span>
    <span>
        <link href="{router.asPath}" locale="en"
            <a onClick="{handleClick}"><img width="30px" className={locale == 'en' ? 'selected' : ''} src="/images/flags/gb.png"/></a>
        />
    </span>
</div>

What I should change to fix it?

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

0

use fat arrow while calling function. like onClick = {() => handleClick()}. i will get bind to event. will not get called on first html render.

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!