Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,161,510 members, 7,847,113 topics. Date: Saturday, 01 June 2024 at 11:15 AM

Should I Be Using Sass With React? - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Should I Be Using Sass With React? (294 Views)

How To Install Sass? / Bootstrap Vs SASS Vs Material UI / Programmer Needed For Full Time Work Must Be Using A Mac Or Linux For The Job (2) (3) (4)

(1) (Reply)

Should I Be Using Sass With React? by Nobody: 1:39pm On Mar 21, 2022
Having used sass for sometime now I’ve gotten quite used to it for obvious reasons. The things I really enjoy about is obviously the nesting of classes which follows the natural order of the DOM tree and makes it very easy to organize and make out the flow of your css and also the fact that you can dynamically define your media queries and include them wherever you want using mixins.
But react advocates for structuring components into individual folders containing the style sheet for that particular component as well. I feel like this approach would now make nesting less useful, there might even be conflicts as well as components are no longer static HTML tags but dynamic JavaScript.
Also would the dynamic media queries still work with mixins?
Is there any react guy that uses sass here?
Did you suffer any trade-off to use sass in react?
Re: Should I Be Using Sass With React? by jikins(m): 1:46pm On Mar 21, 2022
Rgade:
Having used sass for sometime now I’ve gotten quite used to it for obvious reasons. The things I really enjoy about is obviously the nesting of classes which follows the natural order of the DOM tree and makes it very easy to organize and make out the flow of your css and also the fact that you can dynamically define your media queries and include them wherever you want using mixins.
But react advocates for structuring components into individual folders containing the style sheet for that particular component as well. I feel like this approach would now make nesting less useful, there might even be conflicts as well as components are no longer static HTML tags but dynamic JavaScript.
Also would the dynamic media queries still work with mixins?
Is there any react guy that uses sass here?
Did you suffer any trade-off to use sass in react?

It depends on how you are rendering it. I stand to be corrected but react loads all files on start up unless maybe you use lazy loading for your components. So conflict will arise if you styled a class in one component and try using the same class with different styles in another.

With sass you avoid this by nesting all your component styles under the component class name. This prevents conflicts. As I can style a p tag in one component and be rest assured p tags in other components are untouched. Yeah mixins works

1 Like 1 Share

Re: Should I Be Using Sass With React? by Nobody: 2:25pm On Mar 21, 2022
jikins:


It depends on how you are rendering it. I stand to be corrected but react loads all files on start up unless maybe you use lazy loading for your components. So conflict will arise if you styled a class in one component and try using the same class with different styles in another.

With sass you avoid this by nesting all your component styles under the component class name. This prevents conflicts. As I can style a p tag in one component and be rest assured p tags in other components are untouched. Yeah mixins works
Thanks a lot. This is a refreshing answer.

(1) (Reply)

How To Download Slack On Windows10 / Dayfied Social Platform / I Need Google Play Console

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.