Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit ac046a4

Browse files
committed
fix: add i18n.language to translate callback deps for React Compiler compatibility
1 parent cc86049 commit ac046a4

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 is included in deps because i18n is a singleton whose reference
37+
// never changes, but we need to recreate the translate function when language changes
38+
// to ensure React Compiler doesn't over-cache translation results
3639
const translate = useCallback(
3740
(key: string, options?: Record<string, any>) => {
3841
return i18n.t(key, options)
3942
},
40-
[i18n],
43+
// eslint-disable-next-line react-hooks/exhaustive-deps -- i18n.language triggers re-memoization when language changes
44+
[i18n, i18n.language],
4145
)
4246

4347
return (

0 commit comments

Comments
 (0)