Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flicker of Unstyled Content (FOUC) with Gatsby and Material UI #15097

Closed
cadamsdev opened this issue Jun 25, 2019 · 7 comments
Closed

Flicker of Unstyled Content (FOUC) with Gatsby and Material UI #15097

cadamsdev opened this issue Jun 25, 2019 · 7 comments
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@cadamsdev
Copy link

cadamsdev commented Jun 25, 2019

Description

When I visit my deployed site (blog.chadalen.com) there's a flicker of unstyled content for a brief tick. This doesn't happen locally only when I use yarn run deploy

I know this is a duplicae of #5667 and #12644

but those two issues don't solve the issue for me. Hopefully this helps other people who are using material ui as well.

You can see this issue happening at blog.chadalen.com

Describe the issue that you're seeing.

Brief flicker of unstyled content
https://i.imgur.com/HqHa63z.gif

Steps to reproduce

You can clone my project that it appears on
https://github.com/chadalen/blog.git

use gatsby build and publish to github pages

or you can see it live at blog.chadalen.com

Expected result

Should not see unstyled content

Actual result

Unstyled content appears

Environment

Production, GitHub pages

Run gatsby info --clipboard in your project directory and paste the output here.

System:
OS: Linux 5.0 Ubuntu 19.04 (Disco Dingo)
CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 10.15.2 - /usr/bin/node
Yarn: 1.16.0 - /usr/bin/yarn
npm: 5.8.0 - /usr/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 75.0.3770.90
Firefox: 67.0.3
npmPackages:
gatsby: ^2.10.0 => 2.10.0
gatsby-plugin-react-helmet: ^3.1.0 => 3.1.0
gatsby-source-filesystem: ^2.1.0 => 2.1.0
gatsby-transformer-remark: ^2.5.0 => 2.5.0
npmGlobalPackages:
gatsby-cli: 2.7.0

@gatsbyjs gatsbyjs deleted a comment from gatsbot bot Jun 25, 2019
@freiksenet
Copy link
Contributor

Hello @chadalen!

This is happening because styles are included on client-side, but aren't included in the SSR'ed version of the page. gatsby-plugin-material-ui handles SSR for Material UI, I wonder if you could try if that helps with that issue.

Thank you for using Gatsby! 💜 💪

@freiksenet freiksenet added the status: awaiting author response Additional information has been requested from the author label Jun 25, 2019
@cadamsdev
Copy link
Author

@freiksenet Ok thanks, I will try that when I get home :)

@cadamsdev
Copy link
Author

@freiksenet It seems to still flicker. I followed this link https://www.gatsbyjs.org/packages/gatsby-plugin-material-ui/ and I also referenced https://github.com/mui-org/material-ui/tree/master/examples/gatsby any idea what I did wrong?

@sidharthachatterjee
Copy link
Contributor

@chadalen I cloned your repository and did manage to reproduce this! It seems like styles are not being injected at build time like @freiksenet suggested above.

Screenshot 2019-06-26 at 6 33 26 PM

It looks like CSS in https://github.com/hupe1980/gatsby-plugin-material-ui/blob/08b3937d92bc1998e1f935565a070f4a72127393/gatsby-plugin-material-ui/src/gatsby-ssr.js#L43 is empty

Would you like to open an issue in https://github.com/hupe1980/gatsby-plugin-material-ui?

@sidharthachatterjee sidharthachatterjee added type: question or discussion Issue discussing or asking a question about Gatsby and removed status: awaiting author response Additional information has been requested from the author labels Jun 26, 2019
@cadamsdev
Copy link
Author

@sidharthachatterjee Hey thanks for the info. :) Yes I will open an issue there.

@oliviertassinari
Copy link
Contributor

Did you consider opening an issue on https://github.com/hupe1980/gatsby-plugin-material-ui?

@cadamsdev
Copy link
Author

@oliviertassinari issue resolved at mui/material-ui#16390

Thanks guys :D

brandon-julio-t added a commit to brandon-julio-t/personal-website that referenced this issue May 5, 2020
…atsby-plugin-material-ui`

SSR for Material UI is required  to prevent Flicker of Unstyled Content (FOUC)

Reference: gatsbyjs/gatsby #15097
gatsbyjs/gatsby#15097
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

4 participants