Skip to content

Commit 7363ef7

Browse files
committed
fix(i18n): use single-line eslint-disable comment and remove duplicate comment
1 parent d2e3561 commit 7363ef7

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

‎webview-ui/src/i18n/TranslationContext.tsx‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,13 @@ 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.
40-
/* eslint-disable react-hooks/exhaustive-deps */
41-
// i18n.language must be included: i18n is a singleton whose reference
42-
// never changes, but language changes via changeLanguage()
36+
// eslint-disable-next-line react-hooks/exhaustive-deps -- i18n is a stable singleton; i18n.language must be listed explicitly to bust the memo on locale change
4337
const translate = useCallback(
4438
(key: string, options?: Record<string, any>) => {
4539
return i18n.t(key, options)
4640
},
4741
[i18n, i18n.language],
4842
)
49-
/* eslint-enable react-hooks/exhaustive-deps */
5043

5144
return (
5245
<TranslationContext.Provider

0 commit comments

Comments
 (0)