diff --git a/src/context/UserContext.js b/src/context/UserContext.js index 5a2dc21..e5938b6 100644 --- a/src/context/UserContext.js +++ b/src/context/UserContext.js @@ -39,11 +39,11 @@ export function UserContextProvider({ children }) { const currentCountry = CountriesJSON.find( (countryJson) => countryJson.alpha2 === country.iso.toLowerCase() ); - setCountry({ ...country, label: currentCountry[language.toLowerCase()] }); - console.log("currentCountry", country); - - // eslint-disable-next-line - }, [language]); + // setCountry({ ...country, label: currentCountry[language.toLowerCase()] }); + if (currentCountry && currentCountry[language.toLowerCase()] !== country.label) { + setCountry({ ...country, label: currentCountry[language.toLowerCase()] }); + } + }, [language, country]); function changeUserLanguage(newLanguage) { setLanguage(newLanguage);