Comments on: Different Ways to Write CSS in React https://css-tricks.com/different-ways-to-write-css-in-react/ Tips, Tricks, and Techniques on using Cascading Style Sheets. Tue, 05 Jul 2022 09:53:45 +0000 hourly 1 https://wordpress.org/?v=6.2.2 By: Hans https://css-tricks.com/different-ways-to-write-css-in-react/#comment-1796304 Tue, 05 Jul 2022 09:53:45 +0000 https://css-tricks.com/?p=366452#comment-1796304 In reply to fewfewfewfewfewef.

Tailwind is a Library, not a language.
Makes sense not to include it.

]]>
By: Hans https://css-tricks.com/different-ways-to-write-css-in-react/#comment-1796303 Tue, 05 Jul 2022 09:51:39 +0000 https://css-tricks.com/?p=366452#comment-1796303 Out of fairness as a CSS developer, I request a JS in CSS feature.

I also want to be able to butcher another language I can’t write.

]]>
By: gavin https://css-tricks.com/different-ways-to-write-css-in-react/#comment-1796230 Wed, 29 Jun 2022 10:38:27 +0000 https://css-tricks.com/?p=366452#comment-1796230 worth mentioning the react team now not advising css-in-js

https://github.com/reactwg/react-18/discussions/110

“Our preferred solution is to use for statically extracted styles and plain inline styles for dynamic values. E.g. <div style={{...}}>.

You could however build a CSS-in-JS library that extracts static rules into external files using a compiler. That’s what we use at Facebook.

It’s tempting to use dynamically generated style sheets since it contains only the rules that are active on the page right now. However, this comes at a cost. Usually at the expense of runtime cost. It also comes at a cost of inserting new rules frequently which invalidates a lot of the work that has already been done.

Shared stylesheets are efficient to parse and are very cacheable. By extracting them into shared styles you are also effectively batching a lot of that work up front. This lets you avoid doing that work later on as the user starts interacting with the page.

]]>
By: Saleh Mubashar https://css-tricks.com/different-ways-to-write-css-in-react/#comment-1796172 Sat, 25 Jun 2022 13:03:49 +0000 https://css-tricks.com/?p=366452#comment-1796172 In reply to Már Örlygsson.

Hi,
Thanks for the tips
Yes, I should have explained further in detail abut the first 2 points you mentioned
As for the styled components, my apologies, it was a mistake and it is corrected
thanks

]]>
By: Steven Davis https://css-tricks.com/different-ways-to-write-css-in-react/#comment-1796170 Fri, 24 Jun 2022 22:56:45 +0000 https://css-tricks.com/?p=366452#comment-1796170 Nice. I used Styled Components and love it. The power of SCSS and Javascript, but still normal CSS syntax.

]]>
By: Már Örlygsson https://css-tricks.com/different-ways-to-write-css-in-react/#comment-1796166 Fri, 24 Jun 2022 13:15:18 +0000 https://css-tricks.com/?p=366452#comment-1796166 The article contains several errors and inaccuracies that will cause newbies to trip up.

Importing CSS or CSS modules is not a feature of React, and will only work if you’re either using a framework that is configured to support it, or have set it up yourself.
This point is important.
In fact React is neither a Programming language, nor a framework. It’s just a JavaScript library to help with rendering live (HTML) UIs. React is but a tiny cog in the gearwork and the styling options are another, separate cog.
The CSS modules example exports .font but the JSX code uses .heading. This is confusing for anyone lacking prior knowledge of how CSS modules behave.
Styled components should never be defined/constructed inside another component’s render function. (In fact no components should be.) This will cause poor performance and very unpredictable rendering behavior.

]]>
By: fewfewfewfewfewef https://css-tricks.com/different-ways-to-write-css-in-react/#comment-1796165 Fri, 24 Jun 2022 12:28:08 +0000 https://css-tricks.com/?p=366452#comment-1796165 Tailwind and SCSS-modules should be mentioned as well.

]]>
By: Steve https://css-tricks.com/different-ways-to-write-css-in-react/#comment-1796147 Thu, 23 Jun 2022 07:06:08 +0000 https://css-tricks.com/?p=366452#comment-1796147 Thank you.
Nice summary!

]]>