From 9eb331cfe1f8bfe36b0edba478732cdde9cd9f79 Mon Sep 17 00:00:00 2001 From: Sergio Betanzos Date: Mon, 18 Apr 2022 18:47:05 +0200 Subject: [PATCH] M #~: Remove react hook from translate function (#1950) --- .../src/client/components/HOC/Translate.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/fireedge/src/client/components/HOC/Translate.js b/src/fireedge/src/client/components/HOC/Translate.js index 33fad8462a..98ae2222a0 100644 --- a/src/fireedge/src/client/components/HOC/Translate.js +++ b/src/fireedge/src/client/components/HOC/Translate.js @@ -21,7 +21,6 @@ import { useEffect, Provider, createContext, - useMemo, } from 'react' import PropTypes from 'prop-types' import root from 'window-or-global' @@ -68,19 +67,15 @@ const translateString = (word = '', values) => { const { hash = {} } = useContext(TranslateContext) const { [word]: wordVal } = hash - const translation = useMemo(() => { - const ensuredWord = wordVal || word + const ensuredWord = wordVal || word - if (!ensuredWord || !values) return ensuredWord + if (!ensuredWord || !values) return ensuredWord - try { - return sprintf(ensuredWord, ...values) - } catch { - return word - } - }, [word, values]) - - return translation + try { + return sprintf(ensuredWord, ...values) + } catch { + return word + } } /**