user13157154
user13157154

Reputation:

Same css is working for all components without importing it

I am learning react in which I am making components and making css file for each component but if I make a className lets say "temporary" then if I make another component and while I am not importing the previous component's css file but then also if i give the class "temporary" to any other element of this component then also it take the css styling. Why is this happening I don't know.

Upvotes: 1

Views: 267

Answers (1)

Ali Sadeghi
Ali Sadeghi

Reputation: 36

You create multiple CSS files and several components in your React project and connect them if needed. But this is what you see, not what happens. React actually converts all your CSS code into a file and then outputs it. This is also true for components. You create dozens of CSS and JS files, but React creates two files for you. In Recycling, we only create a few files to write more readable code. If you have a problem with this, you can research the module.css in React and use it to prevent this from happening to you. Again, if you have any questions about this, I am at your service.

Upvotes: 1

Related Questions