-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Remove _ctor field from Lazy components #18217
Conversation
We can type each condition.
This field is not needed because it's only used before we've initialized, and we don't have anything else to store before we've initialized.
We try not to break across minors but it's no guarantee.
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 01bf197:
|
Details of bundled changes.Comparing: 2fe0fbb...01bf197 react-dom
react-native-renderer
react-art
react-test-renderer
react-reconciler
ReactDOM: size: 🔺+0.1%, gzip: 🔺+0.1% Size changes (stable) |
Details of bundled changes.Comparing: 2fe0fbb...01bf197 react-art
react-dom
react-test-renderer
react-native-renderer
react-reconciler
Size changes (experimental) |
lazyComponent._status = Pending; | ||
const ctor = lazyComponent._ctor; | ||
let ctor = lazyComponent._result; | ||
if (!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.
Coercion is OK here?
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.
When we detect existence of something unknown things we tend to do this type of check.
The "react" package owns the data structure of the Lazy component. It creates it and decides how any downstream renderer may use it.
export const Uninitialized = -1; | ||
export const Pending = 0; | ||
export const Resolved = 1; | ||
export const Rejected = 2; |
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.
I also upstreamed all of this to the isomorphic package since it owns this data structure. I'll think a bit how we can move the other two helpers out of /shared
.
Apparently we can't depend on react/src/ because the whole package is considered "external" as far as rollup is concerned.
This field is not needed because it's only used before we've initialized, and we don't have anything else to store before we've initialized.
This isn't an important perf optimization by itself but this refactor is motivated by lining it up with the same work on Blocks.