✨ keith is

Export from import

2020 December 10th
2
Back to Snippets

I needed to create a central file in a folder that imported all of the components and exported them.

This started small, but quickly got tedious:

javascript
import Header from './header';
import Wrapper from './wrapper';
import Footer from './footer';
export { Header, Wrapper, Footer }

Adding a new component meant importing it, and then exporting it. Then, a coworker showed me this syntax:

javascript
export { default as Header } from './header';
export { default as Wrapper } from './wrapper';
export { default as Footer } from './footer';
home