-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Emotion does not create style tags using Next.js #1644
Comments
Seems like you didn't setup SSR correctly. Which |
i'm using
this is to use .scss file (other styles that i not use with emotion) |
You need to look into integrating with this API: SSR usually requires some additional setup (especially when you are using |
edit: i add "emotion" in plugins in the .babelrc file, now i have the style tags, but he problem keeps happening, watch this video |
Babel plugin, as far as I know, is completely irrelevant here. The important part is that there are no SSR-ed emotion-related style tags, which is easily inspectable by viewing your site's source: view-source:https://webstation.dev/ . This means that you have not setup emotion correctly, especially on the server. You need to make use of linked APIs |
Well, the only thing I noticed is that now I have |
https://github.com/flakesrc/webstation.dev/ the problem is in sections/presentation and header |
This example https://github.com/zeit/next.js/tree/master/examples/with-emotion-fiber shows how to do what you are trying to do. |
Hi, same problem. But it looks like: (on this commit) I've updated emotion in the example from v8 to v10, the changes are there in this commit: azizhk/next-9-emotion-10-inject-global-bug@25c8bbe |
@azizhk you should change this: -import { keyframes, css, injectGlobal } from 'emotion'
+import { injectGlobal } from 'emotion'
+import { keyframes, css } from '@emotion/core' Keep in mind though that even with those changes the whole example might not work as expected in some regards - mainly due to how you mix vanilla emotion into it. With emotion 10 you shouldn't have to use vanilla emotion with React, you can just use |
Can you expand or if there is some documentation on this. (Can document if you point me to issues.)
Yeah we had a couple of issues, Multiple Style Tags (#1370) First Child Selectors (#1178) Also wanted to ask if extractCritical would be slower than normal approach? Should we measure? |
Ok, I understand this now,
I've updated the example in the next.js repo: vercel/next.js#9646 |
Yes - that's the difference. By using custom data types in the latter case we can have CacheProvider API which wouldnt be possible if we'd have returned plain strings.
Gonna take a quick look. |
@Andarist The link you give to Next.js Emotion Fiber example should be added to SSR doc page, because currently, when I read this page, it says there is nothing to do with Next.js which is wrong (if I do nothing, <style> tags are added after the component). More |
For anyone interested with a real use-case example, check out https://github.com/UnlyEd/next-right-now Interesting parts are: |
The issue has become offtopic - if you experience problems with setting up Emotion with some framework please open a new issue in which we are going to be able to focus on aiding you. Right now it doesn't seem there is anything actionable for us here. |
What happened before: I used
css
to add styles, which creates a class for the element and also injected the styles into<head> <style>
..., now using next.js, it doesn't but instead, I think the style is being injected through js files, and that gives me a problem: the styles are applied after the component appears on screen, so in my case I have a really big image , and I use emotion to setwidth
, so when the screen is loaded, the image takes over the full screen, and only after that the emotion style, which defineswidth
is applied.And I don't know what to do to solve it. Any suggestion? My site is live at https://webstation.dev, maybe on first load you will see that the images cover the entire screen, and only a few milliseconds that the emotion style is applied, and the image gets its expected size.
The text was updated successfully, but these errors were encountered: