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
Anonymous DEV
Anonymous DEVOPβ€’16mo 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";????
Chooβ™šπ•‚π•šπ•Ÿπ•˜
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 DEVOPβ€’16mo ago
how do i use css from index.css which is not a module? cant i use it like i used to do before??
Chooβ™šπ•‚π•šπ•Ÿπ•˜
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 DEVOPβ€’16mo ago
in the name of the file? in tutorial i watched they said i have to write module in it
Chooβ™šπ•‚π•šπ•Ÿπ•˜
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.
Want results from more Discord servers?
Add your server