-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
FOUC: Warning: Text content did not match. Server: "...css..." #3108
Comments
Hmm what could be happening as a rough guess is because it's being precompiled with babel and babel-polyfill is being used, its not getting passed through the styled-jsx when its being rendered on the server for some reason. Not sure. |
I'm getting this as well. I believe it has to do with the CSS being encoded when rendered. Here's the full warning message I receive:
|
Also getting stuff like this, which seems related:
If it has |
I tried reproducing it but in the simple case it seems fine. |
@e10jc nice I see what you mean. It looks like its the encoding of those quotes and probably other stuff. Simple case:
But that itself isn't causing the FOUC. Still not sure about that. |
Looking at the HTML elements debugger in Chrome, there is a ~1s delay to add the title tags (and anything following that in the head perhaps?):
The title appears a few frames afterward. Maybe its related to that. |
YAY It is the encoding! Here is an example to see it:
The quotes get mangled and so it will be Times New Roman or whatever before the client-side styles are applied. View-source looks like this:
Seems like that doesn't work in the browser. |
But, it looks like it only happens with an external repo? Not sure. |
This repo demonstrates the bug: https://github.com/lancejpollard/next-2-repos cc @giuseppeg |
@lancejpollard first thing I noticed is that Also make sure that you always use the latest version of styled-jsx - in 2 beta there was a bug which caused fouc indeed. Though it seems that in your app it resolves to 2.1.1 nonetheless. That said, in case you still see FOUC let me know and I will try to take a look - any help is appreciated ofc, you are all pretty smart folks so I believe that you can debug as I would do too :) Check with the Next.js folks and see whether Next (OR your custom server) encodes SSR code also. |
By the way you might need to export |
@lancejpollard I guess because Next doesn't transpile |
Yeah, maybe some way could be added to handle that. Changing the order didn't work. |
@arunoda maybe we can have this be configurable somehow (excluding node_modules): https://github.com/zeit/next.js/blob/master/server/build/webpack.js#L196-L288 This is the output from trying to load the module without transpiling:
|
oh yea I meant, if you run |
I tried tinkering with the webpack.js file but to no avail. Maybe someone could point me to where this sort of feature (loading external modules as jsx) could be implemented (what changes would need to be made). |
@lancejpollard yeah I am afraid that Next won't transpile |
We're going to implement transpiling node_modules in a future release. Till then you can use something like this example: #3732 |
Still happening. With the basic template provided by the tutorial and the following controller:
Browser somehow receives html encoded version of characters. |
I want to know what method you used to solve last. |
@Weipengzhou if by last you mean mine then I didn’t work out a solution yet. If I do I will post updates here. |
becomes
gives a warning but still applies the padding ( next 7.0.2 ) |
I have the same issue still. I import the css style in string from external *.js file. It give me a warning.
Fortunately, css style is working... I'm using next 7.0.2 now. But I didn't encounter this issue when I using next 6. |
I have the same issue body > div {
/* ... */
} becomes body > div {
/* ... */
} Even though the style was being applied properly, the warning was disruptive enough (I use the console extensively in my day-to-day development) for me to try the following: // Originally I was applying my theme like this from a HOC that wraps "themeable" components
<style
jsx="true"
global="true"
>
{`${theme.shades[shade][componentName]}`}
</style>
// Replaced with this awful thing
<style
jsx="true"
global="true"
dangerouslySetInnerHTML={{__html: theme.shades[shade][componentName]}}
/> This got rid of the warning but now the "de-dupe" functionality is broken and I get as many style definitions for each component as the number of said component's instances, which just kills performance at the scale of apps I'm working with. |
Getting large error (printing all of CSS used in
<style jsx global>
) in web console.I think this is causing FOUC, so there is a flash of unstyled content followed by a second later the actual styles.
This is coming from a library being used in a next project (from #3088).
Expected Behavior
Current Behavior
To elaborate a little more, when rendering a next app in the library itself (so some page in that repo), the styles render fine. View-source shows source maps and minified CSS in the HTML markup.
However, when using that same code as a compiled project loaded into a separate next app, the markup in view-source shows unminified CSS and no source maps (and we get the web console error and fouc).
Steps to Reproduce (for bugs)
babel <folder> --out-dir ... etc.
, and then importing that and also importingbabel-polyfill
if that matters.Context
This is just unexpected behavior making the app not look right (ux).
Your Environment
The text was updated successfully, but these errors were encountered: