Skip to content

Use of default exports when exporting a single module #1

@gruckionvit

Description

@gruckionvit

Hi,

I am loving the detail in the readme. Please could you share your opinion on the export default vs export { named } debate.

When exporting with default, e.g. a react component.

./components/MyButton.tsx

const MyButton = () => (<div><div/>);
export default MyButton;

I am free to import this with any name that I please;

App.tsx

import SomeButton from "./components/MyButton";

...

This is not ideal for refactoring and avoiding typos in the names. If we also switch too exporting multiple modules from the same file we then have to refactor the exporting approach and all the references to it.


Thank you for taking the time to read this, I would love to hear your opinion on the above. Thanks again for what you have share :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions