-
-
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
Add dev hint about css object (generated by Babel) being stringified by accident #1569
Conversation
🦋 Changeset is good to goLatest commit: 32fa5ac We got this. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
52a96cc
to
c63c457
Compare
Codecov Report
|
@@ -129,6 +136,7 @@ const SomeComponent = styled.div({ | |||
↓ ↓ ↓ ↓ ↓ ↓ | |||
|
|||
import _styled from \\"@emotion/styled-base\\"; | |||
var _EMOTION_STRINGIFIED_CSS_ERROR__ = \\"You have tried to stringify object returned from \`css\` function. It isn't supposed to be used directly (e.g. as value of the \`className\` prop), but rather handed to emotion so it can handle it (e.g. as value of \`css\` prop).\\"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should - stupid mistake 🤦♂ fixed!
c63c457
to
7a6a458
Compare
7a6a458
to
32fa5ac
Compare
t.returnStatement(t.stringLiteral(CSS_OBJECT_STRINGIFIED_ERROR)) | ||
]) | ||
) | ||
cssObjectToString._compact = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A hint for babel generator, in this case it doesnt matter much - can remove it if you prefer to omit this.
It basically tells generator to print the statement in a single line, so instead of
function a() {
return 42
}
it prints
function a() { return 42 }
Babel is using this flag when inserting helpers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!!
Followup to #1219 . I haven't noticed before that Babel can generate this object too, so it bypasses the runtime serialization and thus it doesn't have this warning attached to it.