#StackBounty: #javascript #reactjs #aws-amplify React select input value is not resetting on page refresh

Bounty: 100

FWIW, I’m using Gatsby deployed with AWS Amplify.

I have a simple language switcher on my website. When I open the site in a new tab, or in private browsing, the behavior is as expected. It currently defaults to english and you can switch to German. However when I just do a simple refresh, the translatable text on the page goes back to english, while what’s shown in the select is "German". What’s most curious, however, is that inspecting the select looks like the attached picture. While on the page it shows German selected, in the HTML the English option has selected="". Which is correct, but why does it show German?

  const changeLanguage = (lang) => {
    i18n.changeLanguage(lang);
  };
...
 <select
  value={i18n.language}
  onChange={(event) => changeLanguage(event.target.value)}
              

language switcher


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.