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.

Content jump and css issue in Next JS

See original GitHub issue

What is the recommended way to integrate mui v5 in next js

  • [x ] The issue is present in the latest release.
  • [x ] I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Content jumps due to css not getting injected in server side when used with withStyles

Expected Behavior 🤔

CSS should get injected and the content should not jump.

Steps to Reproduce 🕹

Steps:

  1. Take the example next js app and write a component and then refresh the page.

Context 🔦

Migrating from v4 to v5 for an application in next js

Your Environment 🌎

`npx @mui/envinfo`
    System:
    OS: Linux 5.4 Ubuntu 18.04.5 LTS (Bionic Beaver)
  Binaries:
    Node: 14.17.1 - ~/.nvm/versions/node/v14.17.1/bin/node
    Yarn: 1.22.11 - ~/.nvm/versions/node/v14.17.1/bin/yarn
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.1/bin/npm
  Browsers:
    Chrome: 93.0.4577.82
    Firefox: 92.0

I followed code written in mui docs code given here https://github.com/mui-org/material-ui/blob/master/docs/pages/_document.js

It injects material sheets which is not given in reference project after adding that the content jump stopped but during regular deployments the content jumps sometimes

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
sjj1991commented, Nov 2, 2021

I think this issue might be related to SSR. On initial build yarn build && yarn start the styles seems to be working fine (even on hard refresh). However, after 60 seconds (set in revalidate) the styles from the SSR pages goes missing, causing the content jump.

2reactions
mnajdovacommented, Oct 14, 2021

It doesn’t look like this bug report has enough info for one of us to reproduce it.

Please provide a CodeSandbox (https://material-ui.com/r/issue-template-latest), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem.

Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content Jumping (and How To Avoid It) | CSS-Tricks
Few things are as annoying on the web as having the page layout unexpectedly change or shift while you're trying to view or...
Read more >
How to stop content jumping when images load? - ITNEXT
Images scale up and down based on its aspect ratio, so knowing this we can use of the oldest CSS tricks to solve...
Read more >
Next.js and Styled-Components: style loading issue
Have you tried using Styled-Components with your Next.js app but can't get the styles to load properly? This is because the server-side ......
Read more >
css - Why do Images suddenly jump to cover full screen when ...
I hope you are doing great, I was facing the same issue (using next/image + FramerMotion) and I fixed it today by abstracting...
Read more >
Basic Features: Built-in CSS Support - Next.js
Yes, if you disable JavaScript the CSS will still be loaded in the production build ( next start ). During development, we require...
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