mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: add i18n.language to translate callback deps for React Compiler compatibility
This commit is contained in:
parent
cc86049f10
commit
ac046a45d1
1 changed files with 5 additions and 1 deletions
|
|
@ -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 (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue