Writing Css in react

whats the best way to write css in react i mean i am writing css for all components in one single style sheet i dont think its a good idea to do that i tried using different style sheets for different components but i notised that stylesheet of parent component also effects the child component what should i do
No description
7 Replies
ChooKing
ChooKing9mo ago
Adding a CSS Modules Stylesheet | Create React App
Note: this feature is available with react-scripts@2.0.0 and higher.
Anonymous DEV
Anonymous DEV9mo ago
<div className={NavbarCss.leftUpperNav "flex" "center"}> how do i use css from index.css now? do i also now have to import it? import IndexCss from "./css/index.module.css";????
ChooKing
ChooKing9mo ago
It has to be imported, but the name has to match the file name. Note that having "module" in the name makes it a module and not having it in the name makes it not a module.
Anonymous DEV
Anonymous DEV9mo ago
how do i use css from index.css which is not a module? cant i use it like i used to do before??
ChooKing
ChooKing9mo ago
You can just import it, but use its proper name. Don't put "module" in the name as you did in your earlier question.
Anonymous DEV
Anonymous DEV9mo ago
in the name of the file? in tutorial i watched they said i have to write module in it
ChooKing
ChooKing9mo ago
You have to write that if you want it to be a module. I thought you said you didn't want it to be a module.