1

How can use imports in ReactJS like this:

import styles from './Login.scss';

Instead of this:

import styles from './Login.module.scss';

The problem is, when I'm importing with the first syntax, no styles are imported.

(Edit: I used Create React App if that matters)

(Edit 2: Seems like I have to follow this and use the solution from here.)

valk
  • 8,655
  • 11
  • 54
  • 76

1 Answers1

0

You can omit importing stylesheets as a module by importing them as:

import './Login.scss';

Then you could apply CSS classes like:

<>
 <SomeComponent className="foobar"/>
<>

However be warned, that by importing them like this, the style rules contained in those files will live in a global scope. If you would like to get more details, I think that this thread could help:

Changing the CSS for a React component has effect on all other pages

Wiktor Bednarz
  • 631
  • 3
  • 7