use outsite of component #814
Unanswered
HasinaNjaratin
asked this question in
Q&A
Replies: 1 comment
-
Unlike the useTranslation hook, we can use here any namespace, it doesn't have to be a namespace defined in the "pages" configuration. It downloads the namespace indicated as a parameter on runtime. import getT from 'next-translate/getT'
// ...
export async function getStaticProps({ locale }) {
const t = await getT(locale, 'common')
const title = t('title')
return { props: { title } }
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to use the function outside of component?
I tried
const { t } = useTranslation();
but i get error :React Hook "useTranslation" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.
Beta Was this translation helpful? Give feedback.
All reactions