An Interest In:
Web News this Week
- March 22, 2024
- March 21, 2024
- March 20, 2024
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
Default vs Named exports
There are two primary ways to export values with JavaScript: default exports and named exports. But you can use one or both of them in the same file. A file can have not more than one default export, but it can have as many named exports as you like
Export Statements:export default function Button() {} // default export
export function Button() {} // named export
Import Statements:import Button from './button.js'; // default export
import { Button } from './button.js'; // Named export
When you write a default import, you can put any name you want after import.
For example, you could write import Banana from './button.js'
and it would still provide you with the same default export.
In contrast, with named imports, the name has to match on both sides. Thats why they are called named imports!
Original Link: https://dev.to/shacodes/default-vs-named-exports-19hj
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To