Skip to content

Commit

Permalink
edit language dropdown useeffect so all instances show the selected l…
Browse files Browse the repository at this point in the history
…anguage
  • Loading branch information
myix765 committed Dec 8, 2024
1 parent eb994d1 commit 8e072a7
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/components/Dropdown/LanguageDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,17 @@ const langMapping = {
Türkçe: "tr",
};




const LanguageDropdown = () => {
const [selectedLang, setSelectedLang] = useState();
const { i18n } = useTranslation();

useEffect(() => {
const savedLang = i18n.language;
if (savedLang) {
const langName = Object.keys(langMapping).find(key => langMapping[key] === savedLang);
const langName = Object.keys(langMapping).find(key => langMapping[key] === savedLang);
setSelectedLang(langName);

}

}, [selectedLang]);
}, [i18n.language]);

const handleSelectLang = (langName) => {
const langCode = langMapping[langName];
Expand Down

0 comments on commit 8e072a7

Please sign in to comment.