Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda