diff --git a/examples/with-react-i18next/lib/withI18next.js b/examples/with-react-i18next/lib/withI18next.js index e2aff8d8..4db21f2f 100644 --- a/examples/with-react-i18next/lib/withI18next.js +++ b/examples/with-react-i18next/lib/withI18next.js @@ -1,4 +1,4 @@ -import { translate } from 'react-i18next' +import { translate, loadNamespaces } from 'react-i18next' import { getInitialProps, I18n } from '../i18n' export const withI18next = (namespaces = ['common']) => ComposedComponent => { @@ -11,8 +11,12 @@ export const withI18next = (namespaces = ['common']) => ComposedComponent => { ? await ComposedComponent.getInitialProps(ctx) : {} - const i18nInitialProps = - ctx.req && !process.browser ? getInitialProps(ctx.req, namespaces) : {} + const i18nInitialProps = ctx.req + ? getInitialProps(ctx.req, namespaces) + : await loadNamespaces({ + components: [{ props: { namespaces } }], + i18n: I18n, + }); return { ...composedInitialProps,