[DevEx Improvement] Remove default export #907
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Initial checklist
Description of changes
Hello everyone,
thank you for your work on
react-markdown!I'm submitting this PR to propose a Developer Experience improvement, by removing the default export in
index.js.The current code exports the
Markdowncomponent (synchronous version) as default.This default export makes it possible to import the module by doing:
In my case I then realised I needed
MarkdownHooks, thus changed my import as usual, to:And here lies the catch: I'm still importing the
Markdowncomponent!I forgot to add curly braces, and the default export happily worked to import the
Markdownin the confusingly namedMarkdownHooksvariable.Removing the default export would force the developer to import using curly braces from the beginning, avoiding this confusing mistake. It's also consistent with how most other packages work.
This PR removes the default export, and updates the docs accordingly.
This article explains other benefits of removing default exports better than I could.
Cheers! 🎲