NextJs example flickers on page load

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
isaachinmancommented, Oct 4, 2018

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-i18next is a great lib, I used it back in 2016 and still think it is a better option than react-intl.

0reactions
jamuhlcommented, Oct 6, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Fix Styled Components Page Flicker in Next.js 12+
If your Next. js application has flickering styles when a page loads, try out this quick fix. If you're seeing flickering styles and...
Read more >
Flickering with React/Nextjs - DEV Community ‍ ‍
Hi guys, i've this behavior happening when i try to test my authentication. I wonder if someone have already deal or knows how...
Read more >
Next.js - trying to implement an initial loading screen but ...
js but when I load the page the body content flashes for a moment before the loader starts. I'm not sure what should...
Read more >
Flickering with React/Nextjs - Reddit
Hi guys, I've I'm building a little app with Nextjs and i'm dealing with authentication. As you see on the video, I'm trying...
Read more >
MDBSideNav - flickering on page load - MDBootstrap
How could we make the sidebar open only when the user clicks and without flickering on the page load? We use NextJS for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found