lch
lch

Reputation: 4951

How to default export a named import in one line?

index.js

import { Human } from 'test';

export default Human;

I am importing a named export Human from test. I am exporting Human as default from index.js to allow others to import Human from index.js instead of test.

Ex:

import Human from 'index';

How to combine the above 2 statements from index.js into one line?

Upvotes: 5

Views: 2167

Answers (1)

Jack Bashford
Jack Bashford

Reputation: 44145

Use as:

export { Human as default } from "test";

This imports Human, changes it to default, and exports it.

Upvotes: 6

Related Questions