Import style React

Asked

Viewed 366 times

1

You can import a style from another directory in the React import?

I tried something similar to what is done in require to change the directory with ".. /" but to no avail.

  • where the directory is, it’s inside the src?

  • 1

    That, I have inside src, a component folder and another Styles, I can apply a style of Styles inside the components or it is better to leave the style.js inside the components folder?

  • It worked out Bruno?

  • 1

    Opa gave yes thanks.

1 answer

1


It can be done like this:

import '../style/style.css'; // ou
import '../style/style.js';

where the two dots means exit the current directory and fall at the root and then type the path of the other directory and the name of css.

If you have multiple directories inside each other, you have to leave with .. until you reach the src, example if it is 3 directory: ../../../

If you want an editor tip use Visual Studio Code, he plays the part of completing.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.