Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

"no-default-export" and React.lazy #4806

Closed
benny-medflyt opened this issue Jul 22, 2019 · 2 comments
Closed

"no-default-export" and React.lazy #4806

benny-medflyt opened this issue Jul 22, 2019 · 2 comments

Comments

@benny-medflyt
Copy link

I like the reasoning behind the no-default-export rule. But the React code-splitting feature (using React.lazy) seems to require the use of default exports. This is documented here:

https://reactjs.org/docs/code-splitting.html#named-exports

I was wondering if anyone else has any thoughts on this, or ways to still use named exports with React code splitting. Thank you

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Jul 27, 2019

Hi @benny-medflyt! You can always disable the rule. Different codebases have different styles, and there's no single rule or ruleset that works for everyone.

#4305 tracks relaxing these stylistic preferences in the default ruleset.

https://palantir.github.io/tslint/usage/configuration/

@benny-medflyt
Copy link
Author

Thanks for the response. I realize that this rule can be disabled.
I actually strongly believe in the reasoning behind the "no-default-export" rule, and agree that default exports should never be used. I opened this issue to check with the community if anyone has a recommendation for how to use "React.lazy" with named exports.

I looked at the code of "React.lazy" and I think it should be possible to re-implement it to so that it does not require default exports. I wonder if anyone has already done this.

Thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants