-
Notifications
You must be signed in to change notification settings - Fork 48.5k
React.lazy #13398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React.lazy #13398
Conversation
Details of bundled changes.Comparing: 2b30828...a15d2a0 react
Generated by 🚫 dangerJS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending changes on the base PR, but this one makes sense.
// Lazily create thenable by wrapping in an extra thenable. | ||
thenable = ctor(); | ||
} | ||
thenable.then(resolve, reject); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though we don't use the return value, others might want to. So it might be worth returning the result of this.
15395e7
to
5af9d75
Compare
then(resolve, reject) { | ||
if (thenable === null) { | ||
// Lazily create thenable by wrapping in an extra thenable. | ||
thenable = ctor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to set the closed over variable (ctor) to null so that it can be GC:ed since it won't be used anymore.
Lazily starts loading a component the first time it's rendered. The implementation is fairly simple and could be left to userspace, but since this is an important use case, there's value in standardization.
f3cfcb4
to
a15d2a0
Compare
Based on #13397
Lazily starts loading a component the first time it's rendered. The implementation is fairly simple and could be left to userspace, but since this is an important use case, there's value in standardization.
Final name is TBD. I went with
lazy
for now because it's short and descriptive.I put it on the main React export because it's small and importing this at the top of every file will get old really quickly.