From e02175e68dfc7707b9523de0a5d1f80998db7beb Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 17 Oct 2025 20:42:36 +0800 Subject: [PATCH] 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. --- src/hooks/useSettingsForm.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useSettingsForm.ts b/src/hooks/useSettingsForm.ts index 8ab6f82..742e735 100644 --- a/src/hooks/useSettingsForm.ts +++ b/src/hooks/useSettingsForm.ts @@ -56,7 +56,7 @@ export function useSettingsForm(): UseSettingsFormResult { } } return normalizeLanguage(i18n.language); - }, [i18n.language]); + }, [i18n]); const syncLanguage = useCallback( (lang: Language) => {