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
[v4 beta] Server rendering not working #1972
Comments
Strange, I couldn't replicate this check error. Is this the only error? If so, deleting the *.stories files is fine. |
Looks like I'm experience the same issue in my Next.js + TypeScript app after upgrading to styled-components v4, but I can't reproduce it in an MWE I've been trying to craft myself 🤔 |
I still can't reproduce the bug in an MWE, but what I see is that all cases of it appear around this kind of code: const XXX = styled.div``;
const YYY = styled(XXX)``;
// <YYY />
The effect this produces looks exactly like @vinpac has described. My dependencies include: "next": "^7.0.0-canary.12",
"styled-components": "^4.0.0-beta.0",
"@zeit/next-typescript": "^1.1.1-canary.3",
"babel-plugin-styled-components": "^1.6.2",
"@types/styled-components": "^3.0.0", babelrc: {
"presets": ["next/babel", "@zeit/next-typescript/babel"],
"plugins": [
[
"babel-plugin-styled-components",
{ "ssr": true, "displayName": true, "preprocess": false }
]
],
"env": {
"production": {
"plugins": [
[
"babel-plugin-styled-components",
{ "ssr": true, "displayName": false, "preprocess": false }
]
]
}
}
} FYI: There was a duplicate // package.json
"resolutions": {
"styled-components": "4.0.0-beta.0"
}, |
@kachkaev any chance you could post some sort of minimal reproduction repo so I can experiment? |
@vinpac trying to run your project and getting this error:
|
@probablyup Just pushed a commit that will probably fix that. Just enforcing that branch |
ah, gotcha |
@vinpac hmm after looking at this, I'm not really sure why. We don't guarantee className consistency across environments unless you're using the babel plugin. Have you explored using the new babel typescript integration? https://babeljs.io/docs/en/babel-preset-typescript |
@probablyup I'm using |
I was able to produce an MWE with no TypeScript involved: What's happening is reeeeally strange though. If you
You can go to However if you remove I got to the MWE by deleting parts of my real app and here is the reason why those two unrelated dependencies are in This problem did not exist in my real app when I was using styled-components v3. The same here: you can downgrade it to v3 in my MWE while keeping all original dependencies and the class mismatch warning will be gone 😱 |
FYI: The bug is still reproducible on |
Upgrading to |
If you see that -0 and -1 on the className mismatch, I think that’s because the ordering of the components in that file is changing between server and client. Usually an issue of differing configs during transpilation |
Or non-deterministic transpilation which is arguably worse 😐 |
Where do you think the error can be coming from? What is different in v4 compared to v3 that could make the bug possible? Interestingly, the wrong class name is on the client, not on the server. |
I’ll keep investigating
…On Thu, Sep 6, 2018 at 8:19 AM Alexander Kachkaev ***@***.***> wrote:
Where do you think the error can be coming from? What is different in v4
compared to v3 that could make the bug possible?
Interestingly, the wrong class name is on the client, not on the server.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1972 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAiy1j6d81kO4FZqQG6aHK-Cn8Yp_J5Aks5uYSDagaJpZM4WbFY5>
.
|
I have absolutely no idea what's going on here. If I remove a dependency like react-apollo, it goes away. If I add it back, it comes back. So it's deterministically interdeterministic. This is really f*ing bizarre. |
Okay this has been a fun debugging experience... multiple versions of hoist-non-react-statics were being used and they conflict with each other. |
Adding this made it go away:
|
you folks should really use semver ranges, but since greenkeeper is no longer running for this branch things have fallen behind in particular, there seems to be an incompatibility with multiple v2.x versions of this package in the same bundle as displayed here: styled-components/styled-components#1972 When I force resolution to a particular h-n-r-s version, the issue goes away. This is true for both next 6 and next 7 canary. But really you folks should use semver carets instead of pinning.
you folks should really use semver ranges, but since greenkeeper is no longer running for this branch things have fallen behind in particular, there seems to be an incompatibility with multiple v2.x versions of this package in the same bundle as displayed here: styled-components/styled-components#1972 When I force resolution to a particular h-n-r-s version, the issue goes away. This is true for both next 6 and next 7 canary.
@probablyup OMG you are a star!!! 🌟 🎉 I'll check this tomorrow on on the weekend – had to revert upgrading to v4 for now. |
you folks should really use semver ranges, but since greenkeeper is no longer running for this branch things have fallen behind in particular, there seems to be an incompatibility with multiple v2.x versions of this package in the same bundle as displayed here: styled-components/styled-components#1972 When I force resolution to a particular h-n-r-s version, the issue goes away. This is true for both next 6 and next 7 canary.
you folks should really use semver ranges, but since greenkeeper is no longer running for this branch things have fallen behind in particular, there seems to be an incompatibility with multiple v2.x versions of this package in the same bundle as displayed here: styled-components/styled-components#1972 When I force resolution to a particular h-n-r-s version, the issue goes away. This is true for both next 6 and next 7 canary. But really you folks should use semver carets instead of pinning.
@probablyup Indeed, putting |
Going to leave this open until the PRs against next are merged |
Thank you for your help! |
you folks should really use semver ranges, but since greenkeeper is no longer running for this branch things have fallen behind in particular, there seems to be an incompatibility with multiple v2.x versions of this package in the same bundle as displayed here: styled-components/styled-components#1972 When I force resolution to a particular h-n-r-s version, the issue goes away. This is true for both next 6 and next 7 canary.
you folks should really use semver ranges, but since greenkeeper is no longer running for this branch things have fallen behind in particular, there seems to be an incompatibility with multiple v2.x versions of this package in the same bundle as displayed here: styled-components/styled-components#1972 When I force resolution to a particular h-n-r-s version, the issue goes away. This is true for both next 6 and next 7 canary. But really you folks should use semver carets instead of pinning.
Ok looks like updates are out for both versions of next, gonna close this. Thanks @timneutkens! |
Thank you for investigating this @probablyup! 🚀 I'm so keen to try styled-components v4 with Next 7.0.0-canary.14, just need to get back home for that 😅 |
Environment
Reproduction
Steps to reproduce
Prop 'className' did not match
Screenshots
This doesn't happen on v3. You can check it the same repository on master branch.
The text was updated successfully, but these errors were encountered: