NextJs example flickers on page load
See original GitHub issueI seem to have great timing - I’m just now looking for a localisation solution for NextJs and see you’ve updated the examples here within the past 24hrs.
However, knowing personally how hard localisation can be with SSR, I downloaded the react-i18next/example/nextjs dir, and did yarn && yarn build && yarn start.
If you then open localhost:3000, you’ll see the page loads, then flashes white, then loads again.
Not sure exactly what’s happening here, but the example can’t be taken seriously in its present state.
Update: If I remove NamespacesConsumer from _app.js and render <Component {...pageProps} /> directly, the flicker stops. So the problem lies somewhere therein.
Further update: If I swap the order of your i18n prop pipe on NamespacesConsumer, the flicker stops:
i18n={i18n || (pageProps && pageProps.i18n)}
However, the flicker seems to stop because the initial render just isn’t happening. In other words, the page simply remains white until the second render happens. This is not really a fix as it seems to negate SSR. I’ve noticed that pageProps.i18n is null on my clientside render, whereas it’s a full object on my serverside render.
It would be great to get a response on this as soon as the maintainers are able.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (8 by maintainers)
Top Related StackOverflow Question
Okay, got it. Thank you for your fast help on this. It’s very likely that I’ll begin development on a production NextJs/react-i18next application soon. I would certainly be willing to put together a PR for the NextJs example here.
I get what you mean about third-party frameworks evolving and having to support them in examples… Thank you for all your work on this,
react-i18nextis a great lib, I used it back in 2016 and still think it is a better option thanreact-intl.yes…i18next-express-middleware has the option build in…the point i’m not sure is how the clientside router takes this up. I know others did this already but never gone the step to implement this in the sample -> might add some additional complexity making understanding it even harder…
Not sure - but if you like to invest time it would be great if you could share your experience doing so.