Answer the question
In order to leave comments, you need to log in
Why use styled-components instead of regular css files?
I’m asking a noob question, to which I haven’t found an answer anywhere: why, when writing a react application for styling components, use libraries like styled-components, etc., why can’t you just write all the styles for component blocks in one file and just inline them in index.html to plug?
Answer the question
In order to leave comments, you need to log in
The official website has a Motivation section . This is the answer to your question.
At a minimum, you will need to use BEM or a similar bike to isolate the styles. StyledComponets allows you not to use selectors in the source code at all (IMHO - the fifth wheel in the component architecture). The library generates isolated selectors by itself.
StyledComponents is not a panacea, just one of the approaches to solving urgent problems with its own advantages and disadvantages.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question