0
votes

I've got a problem with importing css modules to react component.

import React from 'react'
import styles from '../App.css'

const Button = () => (
    ... className={styles.button}...
)

export default Button;

There is no compilation error and stuff like that. Everything seems to by right, but when I run server button looks by default as with no css.

2

2 Answers

0
votes

You need to use Module css must have name App.module.css

Then import

import React from 'react';
import styles from './App.module.css';

And use className={styles.button}

0
votes

The issue is probably in your webpack config - please share

In the css-loader options, ensure the modules option is set to true