fix: prevent language switch state reset caused by dependency cycle
Fixed an issue where clicking the language switcher would cause a brief flash and fail to persist the language change. The root cause was a dependency cycle in useSettingsForm where readPersistedLanguage depended on i18n.language, causing the initialization effect to re-run and reset state whenever the language changed. Changed the dependency from [i18n.language] to [i18n] since the i18n object itself is stable and doesn't change when the language changes, while the function can still access the current language value via closure.
This commit is contained in:
@@ -56,7 +56,7 @@ export function useSettingsForm(): UseSettingsFormResult {
|
||||
}
|
||||
}
|
||||
return normalizeLanguage(i18n.language);
|
||||
}, [i18n.language]);
|
||||
}, [i18n]);
|
||||
|
||||
const syncLanguage = useCallback(
|
||||
(lang: Language) => {
|
||||
|
||||
Reference in New Issue
Block a user