From de73ecd28f8428c026a25225573c971250723528 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 17 Apr 2022 11:01:03 -0700 Subject: Momorize translation function --- modern/src/LocalizationProvider.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modern/src') diff --git a/modern/src/LocalizationProvider.js b/modern/src/LocalizationProvider.js index cc23d724..d2c663a3 100644 --- a/modern/src/LocalizationProvider.js +++ b/modern/src/LocalizationProvider.js @@ -1,4 +1,4 @@ -import React, { createContext, useContext } from 'react'; +import React, { createContext, useContext, useMemo } from 'react'; import usePersistedState from './common/usePersistedState'; import af from '../../web/l10n/af.json'; @@ -155,7 +155,7 @@ export const useLocalization = () => useContext(LocalizationContext); export const useTranslation = () => { const context = useContext(LocalizationContext); const { data } = context.languages[context.language]; - return (key) => data[key]; + return useMemo(() => (key) => data[key], [data]); }; export const useTranslationKeys = (predicate) => { -- cgit v1.2.3