I was looking for a way to have scoped styles that I could use by writing import styles from './my.css' and using them like className={styles.someClass}.
Without setting up anything further than was given here I made it. Any reason why you chose to use styleName? In my case, I'd rather stick to a well established attribute name. On the other hand, I can import more than one module to my components and use other styles. This is useful for when I have global styles that might apply in many places.
I was looking for a way to have scoped styles that I could use by writing
import styles from './my.css'
and using them likeclassName={styles.someClass}
.Without setting up anything further than was given here I made it. Any reason why you chose to use
styleName
? In my case, I'd rather stick to a well established attribute name. On the other hand, I can import more than one module to my components and use other styles. This is useful for when I have global styles that might apply in many places.So
styleName
comes from thebabel-plugin-react-css-modules
plugin. Stolen from their docs:However, there are several several disadvantages of using CSS modules this way:
Using
babel-plugin-react-css-modules
: