I am wondering if it is better to have one massive css files with comments that break the codes into corresponding sections (e.g. footer, header). Or one css file for each component. E.g. header.css, footer.css? What are the pros and cons?
I am wondering if it is better to have one massive css files with comments that break the codes into corresponding sections (e.g. footer, header). Or one css file for each component. E.g. header.css, footer.css? What are the pros and cons?
I don't think the answer is specific to React and is really one of personal preference.
However, I tend to find POD structures easier to work with.
My typical react component uses css modules and looks something like:
# components/Example/styles.module.css
.example {
background:blue;
}
# components/Example/index.js
import styles from './styles.module.css'
class Example extends React.PureComponent {
render () {
return (
<div className={styles.example}>Example</div>
)
}
}
It really depends on a lot of things:
How big is your application/website?
Is this going to be worked on by a team or just yourself?
Is this a hobby project or an actual commercial product?
Single file approach
Pros:
Cons:
Modular approach
Pros
Cons: