Skip to content
Advertisement

How to export Styled Components in one file?

If I have Styled Component JS files like this:

LoginLogo.js

JavaScript

FooterDiv.js

JavaScript

… and more. How would I export them all at once in one file so I could refer to them in one file? For example

App.js

JavaScript

When I export all of the code from both LoginLogo.js and FooterDiv.js in one file, it gives me an error saying theres no default export. If I group them up in one constant and export that constant as default, it gives me an error saying it can’t find LoginLogo and FooterDiv. I’m trying to reduce the amount of files I make.

Advertisement

Answer

You can do whatever you want, default export or named export.

For example named export:

JavaScript

For example default export

JavaScript

It should works!

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement