fixing flags rerenders
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Antoine M 2024-09-13 10:39:40 +02:00
parent 4186850c0d
commit f4d7d4ad40

View File

@ -39,11 +39,11 @@ export function UserContextProvider({ children }) {
const currentCountry = CountriesJSON.find( const currentCountry = CountriesJSON.find(
(countryJson) => countryJson.alpha2 === country.iso.toLowerCase() (countryJson) => countryJson.alpha2 === country.iso.toLowerCase()
); );
setCountry({ ...country, label: currentCountry[language.toLowerCase()] }); // setCountry({ ...country, label: currentCountry[language.toLowerCase()] });
console.log("currentCountry", country); if (currentCountry && currentCountry[language.toLowerCase()] !== country.label) {
setCountry({ ...country, label: currentCountry[language.toLowerCase()] });
// eslint-disable-next-line }
}, [language]); }, [language, country]);
function changeUserLanguage(newLanguage) { function changeUserLanguage(newLanguage) {
setLanguage(newLanguage); setLanguage(newLanguage);