K.A.C Madushan Posted on Feb 18, 2020 How to structure React Projects using styled components? #react #javascript #css Top comments (1) Subscribe Personal Trusted User Create template Templates let you quickly answer FAQs or store snippets for re-use. Submit Preview Dismiss Collapse Expand dastasoft dastasoft dastasoft Follow Full Stack Developer specialized in React and Node. I love learning and teaching technology on my blog. Currently learning Japanese よろしくおねがいします。 Location Barcelona, Spain Work Full Stack Developer Joined Feb 17, 2020 • Feb 19 '20 • Edited on Feb 19 • Edited Dropdown menu Copy link Hide I use styled components mainly on the library of components I'm making and my personal approach is: - MyComponent |- index.js |- MyComponentBase.js |- MyComponent.js index.js only imports and exports MyComponent.js. MyComponent.js imports MyComponentBase.js and creates a styled version, this file handles all de "CSS" and props related to the CSS. MyComponentBase.js it's a regular React component. The downside of working like this is when you implement some ReactDocs the proptypes on the MyComponent are not visible by default. I hope it helps. Code of Conduct • Report abuse Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse
Top comments (1)
I use styled components mainly on the library of components I'm making and my personal approach is:
index.js
only imports and exportsMyComponent.js
.MyComponent.js
importsMyComponentBase.js
and creates a styled version, this file handles all de "CSS" and props related to the CSS.MyComponentBase.js
it's a regular React component.The downside of working like this is when you implement some ReactDocs the proptypes on the
MyComponent
are not visible by default.I hope it helps.