M #~: Remove react hook from translate function (#1950)

This commit is contained in:
Sergio Betanzos authored and Ruben S. Montero committed 2022-04-25 15:12:15 +02:00
1 parent a515e4239d
commit 9eb331cfe1
1 file changed
+7 -12
@@ -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
}
}
/**