✨ keith is

Export from import

2020 December 10th
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:

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:

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