InterviewHubPRO
Section Overview
Q71

Question 71 of 445

Part 1: Core React, JSX & Component Architecture (1 - 77)

16%
React & Modern Frontend (445 Qs)•Part 1: Core React, JSX & Component Architecture (1 - 77)

How to import and export components using React and ES6?

You should use default for exporting the components

jsx
import User from "user";

export default function MyProfile {
 return <User type="customer">//...</User>;
}
<details> <summary><b>See Class</b></summary>
jsx
import React from "react";
import User from "user";

export default class MyProfile extends React.Component {
  render() {
    return <User type="customer">//...</User>;
  }
}
</details>

With the export specifier, the MyProfile is going to be the member and exported to this module and the same can be imported without mentioning the name in other components.