1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

[with-react-i18next] Fix flickering on page change via <Link /> (#4318)

* Fix flickering on page change via <Link />

* Remove process.browser check
This commit is contained in:
Andrew Razumovsky 2018-05-09 16:06:37 +03:00 committed by Tim Neutkens
parent 8588e8d812
commit 0d4d7d840a

View file

@ -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,