What is the correct way to export named components?

Viewed 31

Is there a difference between exporting like this:

export const Foo ...

and this

const Foo ...
export { Foo }
1 Answers

There is not really a difference, with the second approach you could just export a list of names:

After the export keyword, you can use let, const, and var declarations, as well as function or class declarations. You can also use the export { name1, name2 } syntax to export a list of names declared elsewhere. Note that export {} does not export an empty object — it's a no-op declaration that exports nothing (an empty name list). - mdn web docs

Related