-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
The pseudo class ":first-child" is potentially unsafe when doing server-side rendering. Try changing it to ":first-of-type". #18103
Comments
have you fixed it? |
We are not really doing the server-side rendering. Would it be possible to just suppress it not to flood the console? |
Getting this on both 6.5.0 and 6.5.3. |
I thought this was a pretty simple problem of someone adding a
A couple of things to notice:
From debugging into the code it really seems like the issue is caused by the escape hatch comment from this PR not working any more. I don't know enough about the internals of emotion to speculate, but the TLDR is that the comment "element" ends up in a different position (the first child of the parent element) to where the code looks for it (the last child of the sibling). |
@Andarist is this something you can help with? ☝️ |
Based on the linked code I've prepared a minimal repro case and created an Emotion issue: emotion-js/emotion#2763 Emotion 11 has upgraded Sylis to v4 (parser) and it changed how it keeps comments in the generated AST (which can happen with a lot of AST parsers as comments have no clear semantic meaning and attaching them to correct nodes is purely driven by heuristics). That is likely what has changed and why this isn't working for you anymore. I will take a look into this to see if I can fix this in Emotion itself but it might take me some time to get to it. If this problem happens in the fully client-rendered Storybook then as a future-proof workaround you can disable this warning altogether. Just wrap your app with |
@Andarist The provided link did not fix this issue, unless I'm misunderstanding what "wrap your app" means in Storybook terms. |
Same with NextJS without emotion
|
Can somebody share a full repro case of the problem? I'd like to understand the exact context in which you are experiencing this |
@Andarist I created a repro of this issue without |
I get this error after creating my first story and deleting default stories. My package.json:
|
@tianenpang thank you for the repro - I've created a fix here: #18361 |
@shilman I will try to prioritize investigating this in Emotion itself but it can take a moment. |
Egads!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.5.8-alpha.0 containing PR #18361 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
Ooh-la-la!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.5.8 containing PR #18361 that references this issue. Upgrade today to the
|
Please always try to share a repro case in a runnable form - either by providing a git repository to clone or a codesandbox. OSS maintainers usually can't afford the time to set up the repro, even if exact steps are given. |
@Andarist to reproduce run locally:
Open “Button” component and then “Docs” tab: Created repository https://github.com/hudochenkov/storybook-console-error-18103 (difference from steps above is in repo I used React 17 and npm). But error is the same in both cases. |
@Andarist perhaps we need add the same wrapper on the preview side? |
Shall I create a new ticket or this ticket will be re-opened since issue is not fixed and reproducible with standard Storybook templates? |
Thanks @hudochenkov! |
@tmeasday sorry, I'm confused. Shall I create a new ticket or not? :) |
Go for it! |
Describe the bug
When running the storybook, I am getting this warning in my browser console
he pseudo class ":first-child" is potentially unsafe when doing server-side rendering. Try changing it to ":first-of-type".
To Reproduce
I had installed and setup storybook in my react app with
sb
command line tool and after that I upgraded all the addons related dependency to its latestBeta
version.Running the storybook is showing the above warning in the console.
System
"@storybook/addon-actions": "^6.5.0-beta.1",
"@storybook/addon-essentials": "^6.5.0-beta.1",
"@storybook/addon-interactions": "^6.5.0-beta.1",
"@storybook/addon-links": "^6.5.0-beta.1",
"@storybook/builder-webpack5": "^6.5.0-beta.1",
"@storybook/manager-webpack5": "^6.5.0-beta.1",
"@storybook/react": "^6.5.0-beta.1",
"@storybook/testing-library": "^0.0.11",
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: