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

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

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 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