Wednesday, December 27, 2017

Named and default exports in JavaScript

What is the difference between:

A

import { something } from "somethingPackage"

and

B

import something from "somethingPackage"

B is using a default import.  You can you any name you want to replace 'something'.  However, there must be a 'default' export in the package.

A is a named import.  This works if there is an export with the name 'something' in the package.

No comments:

Post a Comment