Emotion: Export cx from `@emotion/core`

Created on 12 Feb 2019  路  5Comments  路  Source: emotion-js/emotion

Hi, would you accept a PR that makes cx a top level export from @emotion/core?

Right now to use it you have to either use <ClassName> or the emotion package.

Most helpful comment

I'm currently trying to use vanilla emotion's cx as a direct replacement for the classnames library. I'm not using it on styles generated by emotion, just for strings + objects. Should I still switch to using the cx provided by the ClassNames component's render prop function? Honestly I'm hesitant because the ClassNames component with its render function is awfully bulky and ugly.

All 5 comments

It's not a good idea within current design, because cx is eager whereas css from @emotion/core core is lazy-ish (it constructs an object, it doesnt insert the styles to the DOM, it also doesnt produce final class name - this happens in jsx).

cx just cant combine regular classes with css output outside of the render functions.

Thanks for the answer, does it mean that the cx exposed by emotion is different from the one of ClassNames?

Oh ok I see, it makes sense then. Sorry for the waste of time!

I'm currently trying to use vanilla emotion's cx as a direct replacement for the classnames library. I'm not using it on styles generated by emotion, just for strings + objects. Should I still switch to using the cx provided by the ClassNames component's render prop function? Honestly I'm hesitant because the ClassNames component with its render function is awfully bulky and ugly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AlexanderProd picture AlexanderProd  路  3Comments

artooras picture artooras  路  3Comments

rockmandash picture rockmandash  路  3Comments

smlmrkhlms picture smlmrkhlms  路  3Comments

sami616 picture sami616  路  3Comments