Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
212 views
in Technique[技术] by (71.8m points)

javascript - React - Should I replace my css files with styled components

My question may turn out to be a little strange, but I want to understand, for example, I have 10 css files in my project and these styles are 90% not repeated. Is it worth using styled components in this case? i.e. replace all these styles with an object?

const Button = styled.button`
  font-size: 2em;
  background-color: black;
  color: white;
`;

I understand that styled components have a lot of advantages. But I want to understand if it is worth replacing the content of 10 css files with styled components? Because perhaps in the future I will need this technology


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

No, I don't think so. If they are not repeatable and reusable and you already have a lot of CSS codes and files, it will take a long time to convert them to Style-component, and also it won't bring too much advantage. Besides the advantages of styled-components, there are some disadvantages too as it is a pure JS and if it is not reusable, it is basically increasing your payload size. SO definitely in your case, I think you should stick to CSS for now.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...