What are some use cases for using named imports with the import keyword (to import a default export)?

Question

What are some use cases for using named imports with the import keyword (to import a default export)?

Answer

We can combine named imports with the import statement (to import a default export) for the same reasons we would combine named exports and default exports.

Generally, this includes importing the expected export of a module, the default export, importing any utility exports that may not be necessary but could come in handy, the named exports, and/or importing pieces of a module that are the internals of a private variable without exposing the entire private variable (again these would be named exports).

5 Likes