fix: add i18n.language to translate callback deps for React Compiler compatibility

This commit is contained in:
Roo Code 2026-01-30 04:24:10 +00:00
parent cc86049f10
commit ac046a45d1

View file

@ -33,11 +33,15 @@ export const TranslationProvider: React.FC<{ children: ReactNode }> = ({ childre
}, [i18n, extensionState.language])
// Memoize the translation function to prevent unnecessary re-renders
// Note: i18n.language is included in deps because i18n is a singleton whose reference
// never changes, but we need to recreate the translate function when language changes
// to ensure React Compiler doesn't over-cache translation results
const translate = useCallback(
(key: string, options?: Record<string, any>) => {
return i18n.t(key, options)
},
[i18n],
// eslint-disable-next-line react-hooks/exhaustive-deps -- i18n.language triggers re-memoization when language changes
[i18n, i18n.language],
)
return (