- Got questions about React or anything else in its ecosystem?
- No question is too simple.
Here’s another weekly Q&A thread! The previous one was…
@dan_abramov: New weekly Q&A thread about React is up! No question is too simple.
Need help with figuring out how to correctly use CSS while making use of CRA. I tried to separate out the CSS for each component independently, but the styles are persisting in the DOM even after the component is removed from the screen. Meaning, if I use a classname called ‘.title’ in X component, the same style is applying to Y component if it is loaded after X component. Is there a way I can bundle the CSS along with the component such that it is automatically removed when the component is not displayed?
I’m struggling about the best way to style my React app, should I use a regular global CSS file and then style my components via className as I would do for a regular HTML file or explore CSS Modules, CSS-in-JS or something else. Every time I want to start something I can’t decide about this and get stuck. Also, what about grid system? I don’t want my components to be dependent on Bootstrap or something like that.