question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Layout breaks on refresh

See original GitHub issue

Current behavior: Page refresh causes layout to break.

This does not happen in development mode. Only on a production build, deployed.

  • We don’t use nth child, only :nth-of-type. This can be used right? I don’t see anything in the docs that say otherwise
  • We use breakpoints
  • This page is rendered with SSR (by NextJS)

Is there any advice on how I can reproduce this? Or narrow down?

Also: it does not always happen. Only after some time it has been deployed. Like a few hours. Caching problems?

I’m having a bit of a hard time finding things to look towards on how to reproduce this or narrow down to a specific part. I understand that it is my job when filing a bug in this repo to give a reproduction. But I’m sort of out of things to look towards to solve this.

To reproduce: Do a page refresh on a specific page.

Expected behavior: Layout does not break on second page refresh.

Environment information:

  • react version: 17.0.2
  • @emotion/react version: 11.8.2
  • nextjs version: 11.1.4

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Andaristcommented, Mar 31, 2022

However: why is it so that the first request, it does not matter; but the second, it messes up the layout.

It’s pretty consistently broken for me. It doesn’t matter “which request” I’m testing at any given moment. Maybe your “first request” doesn’t visit this page directly? And subsequent requests are just direct reloads on that page?

1reaction
srmaguracommented, Mar 31, 2022

Nice investigation Andarist 😀

The server is on UTC, but the client is indeed likely to be in another timezone.

And this is one of the several reasons why I don’t do SSR unless it’s truly necessary 😂. I’ve solved this problem in the past by storing the user’s time zone so that the server can use that time zone when generating the HTML. The user time zone could be stored in the Users table in the database or encoded into the auth token. But if your app allows anonymous visitors, that makes this a lot harder and I don’t know how to handle that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Layout breaks upon refresh using react
Im building a website using React JS and each time I refresh the page the layout breaks. What could be causing this?This is...
Read more >
Responsive layout breaks when resized - need refresh
The problem is that jQuery Cycle isn't responsive. It sets the width of your images and can only change them on refresh. So,...
Read more >
Breaks on page refresh · Issue #434 · desandro/masonry
The layout works perfectly fine if I go to the page directly, or via a href link. If I refresh the page (with...
Read more >
Solved - Page Breaks (CSS) On Refresh! Help!
After refreshing once the css layout will be destroyed and a gigantic list of errors appears. Strangest thing of all: layout remains broken...
Read more >
Basic Features: Fast Refresh
If you make a syntax error during development, you can fix it and save the file again. The error will disappear automatically, so...
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