mdmb
mdmb

Reputation: 5283

Import/ Exports in ES6

I have a file called index.js that I'm importing other modules into, and exporting them using named exports:

import { Card, Icon } from 'some-library';
import ButtonComponent from './Button';

export const Button = ButtonComponent;

My question is - how can I export those named imports from some-library in the same file without changing their names?

Upvotes: 0

Views: 217

Answers (1)

Nicholas Tower
Nicholas Tower

Reputation: 85161

If you want to import a named export and re-export it with that same name, do this:

export { Card, Icon } from 'some-library';

If you want to import a default export and re-export it with some specific name, do this:

export { default as ButtonComponent } from './Button';

Upvotes: 3

Related Questions