Last active
April 7, 2020 16:23
-
-
Save asiniy/81a4d383003d4ee6380d4cc4441a359d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const currentLanguage = 'ru' // store this in global state (redux, window, localStorage, flux et.c.) | |
const countries = [ | |
{ | |
ru: 'Россия', | |
en: 'Russia', | |
}, { | |
ru: 'США', | |
en: 'USA' | |
}, | |
// et.c. | |
] | |
onSelect = (selectedCountry) => { | |
this.setState({ selectedCountry }) | |
} | |
<select onSelect={onSelect}> | |
{countries.map((country) => ( | |
<option selected={country === this.state.selectedCountry}> // maybe, you have to compare values not objects due to shallow comparison | |
{country} | |
</option> | |
)} | |
</select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment