-
-
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
TypeError: Cannot read property 'key' of undefined on server side render #1185
Comments
My first guess is that you still have some old It might be worth it to set a conditional breakpoint there in your app to break when Looking at this more there may be some difference in the entry point of the App on the server and client. Maybe the renderToString call is not calling the "true" top level component or a component above the one being rendered is calling emotion. Maybe an old Global styles call? |
The same issue for our project. We did not upgrade from 9 to 10. We use 10 version right away. Fails on SSR with error:
After debugging we found a hack in Emotion sources in core.cjs.dev.js file if we change line 22 from |
After some time debugging - I have noticed this is due to an old dependancy of I also noticed I needed to install Should I update the docs? I think also the original error message can be improved - maybe it can somehow detect you have old deps based on the code path |
Are you sure @emotion/babel-utils are needed? Seems like some old package which shouldnt be used right now. |
Same error in my project.
and add simple style object:
Looks like in SSR run |
I removed Not sure if this will help anyone else or even if its related to the error message I was getting originally (maybe it was all some sort of co-incidence) I still think that there should be better error messages to indicate something is erroneous or missing |
I encountered a similar error. Some of my transitive dependencies are respectively depending on Emotion 9 & 10. Took me days before I figured out that the error was actually caused by a rogue webpack plugin breaking correct module resolution. Thus making calls to wrong version of the emotion core or util dependency. |
I also ran into this error while running mocha tests, so I needed to make emotion think I was running on a browser by adding |
@winstondispatch could you prepare a repro case for your problem and raise a new issue with it? |
Same problem for me when running tests via Jasmine + JSDOM but the suggestion from @winstondispatch above solved it! |
emotion
version:@emotion/core: 10.0.6
react
version: 16.4.2Relevant code:
What you did:
Seems to be failing for server side render (see error in What happened)
Works on client render.
I tried to migrate from emotion 9 to 10.
I have moved over the component code to use
@emotion/core
and used the import:
I have also removed all the server side render code associated with emotion 9 (eg:
renderStylesToString
)Maybe im missing something?
What happened:
Got this error on server side render (client render is ok):
Reproduction:
Not sure if this is associated with our internal webpack tooling
Hard to reproduce on a code sandbox link with our internal tooling
Problem description:
See above.
Suggested solution:
? Not sure
The text was updated successfully, but these errors were encountered: