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:
parent
8588e8d812
commit
0d4d7d840a
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue