Categories
React Answers

How to use ES6 import alias syntax for React components?

Spread the love

Sometimes, we want to use ES6 import alias syntax for React components.

In this article, we’ll look at how to use ES6 import alias syntax for React components.

How to use ES6 import alias syntax for React components?

To use ES6 import alias syntax for React components, we can use the as keyword.

For instance, we write

import { default as StyledLibrary } from "component-library";

to import a default export from the component-library module.

We add a default export with

export default StyledLibrary;

Conclusion

To use ES6 import alias syntax for React components, we can use the as keyword.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *