diff options
author | Anton Tananaev <anton@traccar.org> | 2022-04-17 11:01:03 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-04-17 11:01:03 -0700 |
commit | de73ecd28f8428c026a25225573c971250723528 (patch) | |
tree | cade7778276181ac57dd37e53eb1c8b82e15ff2a /modern | |
parent | 8b229a4e6b12297c66b54101364800a0abc282a0 (diff) | |
download | trackermap-web-de73ecd28f8428c026a25225573c971250723528.tar.gz trackermap-web-de73ecd28f8428c026a25225573c971250723528.tar.bz2 trackermap-web-de73ecd28f8428c026a25225573c971250723528.zip |
Momorize translation function
Diffstat (limited to 'modern')
-rw-r--r-- | modern/src/LocalizationProvider.js | 4 |
1 files changed, 2 insertions, 2 deletions
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) => { |