Skip to content

Commit ddeb2b7

Browse files
committed
fix(i18n): add i18n.language to translate callback deps
1 parent 71db2e6 commit ddeb2b7

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

webview-ui/src/i18n/TranslationContext.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@ export const TranslationProvider: React.FC<{ children: ReactNode }> = ({ childre
3333
}, [i18n, extensionState.language])
3434

3535
// Memoize the translation function to prevent unnecessary re-renders
36+
// Note: i18n.language must be included as a dependency so that the
37+
// translate function is recreated when the language changes. Without
38+
// this, React Compiler / React.memo consumers will cache stale
39+
// translations because the i18n object reference never changes.
3640
const translate = useCallback(
3741
(key: string, options?: Record<string, any>) => {
3842
return i18n.t(key, options)
3943
},
40-
[i18n],
44+
[i18n, i18n.language],
4145
)
4246

4347
return (

0 commit comments

Comments
 (0)