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?
use fat arrow while calling function. like onClick = {() => handleClick()}. i will get bind to event. will not get called on first html render.