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:
Jason
2025-10-17 20:42:36 +08:00
parent 9fb000b8fe
commit e02175e68d

View File

@@ -56,7 +56,7 @@ export function useSettingsForm(): UseSettingsFormResult {
}
}
return normalizeLanguage(i18n.language);
}, [i18n.language]);
}, [i18n]);
const syncLanguage = useCallback(
(lang: Language) => {