K.A.C Madushan Posted on Feb 18, 2020 How to structure React Projects using styled components? #react #javascript #css Top comments (1) Subscribe Submit Preview Dismiss Collapse Expand dastasoft dastasoft dastasoft Follow 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
Top comments (1)
I use styled components mainly on the library of components I'm making and my personal approach is:
index.jsonly imports and exportsMyComponent.js.MyComponent.jsimportsMyComponentBase.jsand creates a styled version, this file handles all de "CSS" and props related to the CSS.MyComponentBase.jsit's a regular React component.The downside of working like this is when you implement some ReactDocs the proptypes on the
MyComponentare not visible by default.I hope it helps.