Skip to content

Commit 5a8bb46

Browse files
committed
fix: infinite reloads in vite spa build
1 parent e11e79c commit 5a8bb46

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

cmp/compiler/src/react/shared/TranslationContext.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import {
2020
persistLocale,
2121
} from "@lingo.dev/compiler/locale/client";
2222

23+
const noop = () => {};
24+
2325
/**
2426
* Translation context type
2527
*/
@@ -239,8 +241,12 @@ function TranslationProvider__Prod({
239241
}, []); // Only run on mount
240242

241243
useEffect(() => {
242-
setTranslations(initialTranslations);
243-
}, [initialTranslations]);
244+
// TODO (AleksandrSl 08/12/2025): More elegant solution required.
245+
// This is used to update the client part when next app changes locale
246+
if (router) {
247+
setTranslations(initialTranslations);
248+
}
249+
}, [initialTranslations, router]);
244250

245251
/**
246252
* Change locale
@@ -273,7 +279,7 @@ function TranslationProvider__Prod({
273279
locale,
274280
setLocale,
275281
translations,
276-
registerHashes: () => {}, // No-op in production
282+
registerHashes: noop,
277283
isLoading,
278284
sourceLocale,
279285
}}

0 commit comments

Comments
 (0)