-
-
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
Using emotion with Next.js. :first-child selector gives me an error: The pseudo class ":first-child" is potentially unsafe when doing server-side rendering. Try changing it to ":first-of-type". #2917
Comments
Hey guys, if there's no easy way to fix this bug, do you think there can at least be a workaround that would allow me to suppress the error? It doesn't break anything, it just keeps annoying me by showing up in devtools. |
@lumenwrites There is this hilariously-named comment:
(Put it on the same line as the selector) However I'm back here because I'm seeing an issue where the console error has returned, so it may be broken in recent Emotion versions 🙄 See #1105 for some prior discussion. |
We are currently using Emotion + MUI5 + Next.js. I did a bunch of research to see why this warning exists. I read a bunch of Github threads, collecting more details here and there. I did a bunch of testing on dev and prod builds of our app to see if Emotion injectes I never saw Emotion placing For ref: Is this warning completely irrelevant Next.js + MUI5 users? |
Is there any progress on a solution to remove/mute this annoying log? |
Bumping... Just ran into this today on a use case that made sense to not see it. Rendering MDX and need the first child's top margin removed. Hoping to see it muted soon. |
If you want solve problem directly with CSS. /* *:not(:not(:last-child) ~ *) = *:first-child */
*:not(:not(:last-child) ~ *) {
...
} |
If you feel comfortable suppressing the error you can add this one line....
From - #1105 (comment) |
Current behavior:
I'm using emotion with Next.js.
If I use a
:first-child
selector, I see the error in dev tools:But I can't use
:first-of-type
because, well, I need to use:first-child
, and they behave differently.To reproduce:
Create a Next.js project that uses
emotion
, use:first-child
anywhere in CSS.Expected behavior:
Not having an error in the dev tools.
Environment information:
react
version: 18.2.0@emotion/react
version: 11.9.3The text was updated successfully, but these errors were encountered: