-
-
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
@emotion/core vs vanilla emotion #1883
Comments
Just a note - we understand how this name is confusing and we are in the process of renaming this package to
Well, truth to be told - this is the preferred way of using
I don't agree with this statement - you have to only add this import if you are using Note: this part might change in the future though as React has introduced automatic transform recently (babel/babel#11154), we are waiting for the support for it to get released in React itself and for it also being supported by TypeScript team which is on their roadmap (from what I believe).
The goal is to provide predictable styling - we can only do that if we control the styling, thus this actually helps us ensure that you are using emotion-generated styles. Otherwise, you can find yourself in the middle of specificity wars once again.
This really sounds very aggressive and out of place. Even if a little bit quirky render props are still valid for some use cases and this is one of them (at least for us). I'm actively thinking about a different API for this but it has to work with 0 config SSR and that's not an easy feat for this feature. We don't believe this is much of an issue because you rarely should use non-emotion styles (ideally you wouldn't have to use them at all).
Many people are tired of configuring things. The configuration also spills itself on all of the consumers. Emotion is used, sort of, as an engine for multiple other libraries, and with 0config approach they don't have to educate their consumers (who might not even be aware of using Emotion under the hood) that they need to setup something for SSR. It just works.
Well - it's not our responsibility to document how to integrate Emotion with all of the fancy meta frameworks. We understand that we could maybe give guidance on how to integrate with the most popular ones, but there are already dedicated packages for this, so not sure why we should bother duplicating efforts. If you feel that their docs are lacking something you can always try to improve them by providing helpful PR. Also - those packages are only needed if you want to do something custom. 0config approach is, well, 0 config so it doesn't require any extra documentation. That's why we recommend it - we don't have to integrate in any special way with any other tool, things should just work if you stick to the 0 config approach. The time we can spare on the project is also not infinite, so we don't feel like documenting the stuff we don't really recommend.
I believe many would disagree and you also sound very aggressive here which I don't find to be OK. However, we agree that builtin theming is not needed, there is an open PR which we'd like to revive with arguments laid out against it: https://github.com/emotion-js/emotion/pull/973/files . We've found out that people like the builtin theming though, so we are keeping it - but we plan to emphasize that there is a better way of doing things in v11 docs.
Because we don't give you string class names back, but rather just opaque objects, the rule insertion is lazy. This might not be as interesting on its own, but it allows us to customize injection through a
This allows libraries built on top of Emotion don't care about this stuff because, if needed, the final consumer can decide about this stuff.
If the chosen tradeoffs are not for you then you are welcome to continue using vanilla Emotion. We don't plan to remove the support for it. |
@Andarist I really appreciate all this feedback! I want to apologize for the tone - it was far too aggressive in all the cases you mentioned. I got a little carried away. I certainly won't publish this until that's been corrected. I'll admit upfront I haven't been following the API updates coming in v11 - I'll look more deeply into that. I agree that
There's a lot I don't understand about the use cases you're optimizing for. Frankly I hope I never encounter a scenario that necessitates the use of I don't understand how the My primary source of my frustration is something that I only briefly alluded to in my writeup: the documentation explicitly steers people to
It seems like all of these tradeoffs were made in the name of zero-config SSR, which isn't a consideration for a hefty majority of React-based SPAs. My recommendation would be to make these tradeoffs more explicit in a documentation, and two present these approaches as two equally valid options (instead of explicitly recommending core for React projects). Based on npm downloads, it's clear that You should know that all of my thoughts are colored by the fact that I LOVE Thanks again for your feedback. I'll let you know if I decide this post is worth publishing. And great work - seriously. |
After reading Andarist's feedback carefully and doing some additional research, I'm still confident in my assessment that vanilla emotion is a better choice for a hefty majority of React projects. A small number of scenario's warrant the usage of @emotion/core: SSR (though this is quite easy to set up for Next.js or Gatsby), a need to customize the auto-prefixing, and a handful of even less common scenarios. For the average React project, vanilla I published final writeup explaining my reasoning here: https://vriad.com/blog/emotion-core-vs-vanilla-emotion |
Sure, those use cases are not as common - but they happen. Just got a question regarding such use case a 1 hour ago: #760 (comment)
I was referring to your previous remark of:
So in here - we are not really that concerned with the ease of use in codebases not using
Well, I'm really glad that you find vanilla Emotion useful - it certainly is. But it's hard for us to change this rhetoric in the docs as we believe that
I don't understand this point at all, could you elaborate?
As mentioned above - we don't think you should integrate often with external elements, having to add Maybe we could think of auto-adding |
This is required to use the emotion cache, which Automat uses as part of its shadow dom support. In addition, Source uses @emotion/core and standardising helps avoid having to load both. Note, an interesting discussion on the differences between emotion and @emotion/core can be found here: emotion-js/emotion#1883.
This is required to use the emotion cache, which Automat uses as part of its shadow dom support. In addition, Source uses @emotion/core and standardising helps avoid having to load both. Note, an interesting discussion on the differences between emotion and @emotion/core can be found here: emotion-js/emotion#1883.
This is required to use the emotion cache, which Automat uses as part of its shadow dom support. In addition, Source uses @emotion/core and standardising helps avoid having to load both. Note, an interesting discussion on the differences between emotion and @emotion/core can be found here: emotion-js/emotion#1883.
This is required to use the emotion cache, which Automat uses as part of its shadow dom support. In addition, Source uses @emotion/core and standardising helps avoid having to load both. Note, an interesting discussion on the differences between emotion and @emotion/core can be found here: emotion-js/emotion#1883.
This is required to use the emotion cache, which Automat uses as part of its shadow dom support. In addition, Source uses @emotion/core and standardising helps avoid having to load both. Note, an interesting discussion on the differences between emotion and @emotion/core can be found here: emotion-js/emotion#1883.
* Reduce globals * Migrate to @emotion/core from vanilla emotion This is required to use the emotion cache, which Automat uses as part of its shadow dom support. In addition, Source uses @emotion/core and standardising helps avoid having to load both. Note, an interesting discussion on the differences between emotion and @emotion/core can be found here: emotion-js/emotion#1883.
Just to chime in here for a second, as somebody who went in on the typical |
Hey @Alphy11, could you explain the problem you are encountering in more detail? Or provide a CodeSandbox that shows it. I have never gotten the error |
Sorry, this was sent prematurely with too little context. I want to say that I think
Which comes along with loads of types complexity, and digs into React's types since you're accounting for both native elements, AND components. So I get weird error messages like this:
And the problem is almost certainly not with the CSS prop here, but if I want to debug what LibraryManagedAttributes needs to be here, it's no longer a central place. This experience has felt a lot like extending native prototypes (like adding array function). It's super useful, until something goes wrong, and then you're not quite sure where everything comes from. So I would ideally like the ability to opt out of emotion's JSX replacement, and instead just use it as a hook, without any global type extensions, or "magic" while still getting all of the other react features like theme and cache in context. Happy to spin up a sandbox if you're still curious, but seemed a bit irrelevant to the conversation since it's mostly an likely-unrelated TS error |
That is an advanced use case from a TypeScript perspective. To make it work, you'll probably have to dig into the If you want to avoid the complexity introduced by the |
Yeah, totally agree it's way advanced. Just throwing a reason to separate out the react functionality from the JSX pragma. Not worth it just for my use case, but providing the feedback to give the data point! FWIW, |
UPDATE: I published final writeup on this topic here. tl;dr I think vanilla
emotion
is a better option for the majority of React projects: https://vriad.com/blog/emotion-core-vs-vanilla-emotionI'm a huge fan of the
emotion
module but am somewhat bewildered by some of the tradeoffs made in the design of@emotion/core
.I wrote up some thoughts as a blog post but haven't published them yet. I want to give the Emotion team some time to respond to my criticisms. I don't want to put publish a post that misrepresents this package or its design goals. It's very possible I simply don't understand some of the use cases you were optimizing for. Here's a link to a Gist containing the text of my post: https://gist.github.com/vriad/23956586223e36931718399c0caa2eef
I'd hugely appreciate anyone who can shed some light on these decisions for me.
I absolutely love vanilla
emotion
which is why I'm sad to see it getting deprioritized in favor of core. I say this in the post but it's worth repeating: I love Emotion and I'm hugely indebted to your guys for all your great work!The text was updated successfully, but these errors were encountered: