DEV Community

Charles 🛰
Charles 🛰

Posted on

Different ways of export and import

Here we will talk about how and when should we use the import without brackets like this:

import Card from "components/card";
Enter fullscreen mode Exit fullscreen mode

and when we have to use the import with brackets like this:

import { Card } from "components/card";
Enter fullscreen mode Exit fullscreen mode

It depends on how we made the export, if we made a export default we will have to import without brackets like in the first example

whereas if we made an export like this:

export const Card = () => {
 return(

)
}
Enter fullscreen mode Exit fullscreen mode

our import will look like this

import { Card } from "components/card";
Enter fullscreen mode Exit fullscreen mode

Thanks for reading.

Latest comments (0)