r/reactjs • u/steven-f • Sep 05 '18
Tutorial Announcing styled-components v4: Better, Faster, Stronger
https://medium.com/styled-components/announcing-styled-components-v4-better-faster-stronger-3fe1aba1a112
203
Upvotes
30
u/sickcodebruh420 Sep 05 '18
Pretend I’m still in the Stone Age and happily using SASS. What life-changing benefits would I get from using this or something like it?
13
u/[deleted] Sep 05 '18
Wow!! I can't wait to try out 'as', I think it will change the way I create reusable components!
15
u/swyx Sep 05 '18 edited Nov 29 '18
ok i really need an eli5 - what actually sets styled components and emotion apart? i like having tagged template semantics (looks like css) and i like things to precompile into static css (eg with a babel plugin) but it seems like both have them.
so what factually sets the two apart? sorry if this is a dumb question as ive used both in projects but never felt strongly either way.
edit 1: i spent some time googling this question and found this on the emotion repo: https://github.com/emotion-js/emotion/issues/113#issuecomment-334955156
basically kye doesnt care to compare, he just wants to make things his way. a lot of minor departures and some claims about speed. really hard to lean either way.
EDIT 2: direct reply from Kye here: https://twitter.com/tkh44/status/1037396168701952001 pretty succinct!
5
u/nickbreaton Sep 05 '18
Exciting release! Thank you styled components team.
4
u/dance2die Sep 05 '18
Yes! No more
innerRef!That's great since I always decide whether to use simple component or styled one. Having to switch always broke since I forget to change
innerRef <=> refall the time.4
u/dceddia Sep 05 '18
For someone who's still pretty happily using SASS and even plain CSS most the time - what's the workflow like in terms of in-browser CSS hacking?
With plain CSS or SASS, my workflow is usually something like
I really like step #3 there, because the feedback is quick and I don't have to wait for a save + reload/hotreload. Is that still possible + nice with CSS-in-JS?
2
u/brcreeker Sep 05 '18
That new "as" prop is sexy! I see myself using that quite often. Also, LOVE that SC is now using forward refs. That was a major pain point for me. I'll be installing this into a few projects this evening.
3
u/azCC Sep 05 '18
Wonder if these security issues still persist? The release notes mention nothing about fixing them.
https://frontarm.com/articles/how-can-i-use-css-in-js-securely/
1
u/maffoobristol Sep 05 '18
Interesting stuff :) i'd like to see some Y axes on those graphs though. How much of a concrete difference does it make in milliseconds?
1
u/slvrsmth Sep 05 '18
A bit bummed out that
extendis straight up removed, not deprecated. Means I'll be upgrading only when there's time to both upgrade and update the code, rather than splitting that down into two separate tasks.Codemods are fine, but for someone like me that has not used them previously, it's still an unknown time investment.