-
Notifications
You must be signed in to change notification settings - Fork 46.4k
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
Resolve defaultProps for Lazy components #13961
Conversation
'A2', // render | ||
'getSnapshotBeforeUpdate (this.props): A', | ||
'getSnapshotBeforeUpdate (prevProps): A', | ||
'componentDidUpdate: A', |
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.
The test is failing at componentDidUpdate
and getSnapshotBeforeUpdate (this.props)
, as they are coming back undefined
.
const resolvedProps = resolveDefaultProps(Component, props); | ||
const resolvedProps = (workInProgress.pendingProps = resolveDefaultProps( | ||
Component, | ||
props, |
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.
The type and tag are overwritten, so my first thought was that the same should be done for pendingProps
Details of bundled changes.Comparing: 275e76e...50490ed scheduler
Generated by 🚫 dangerJS |
This solves part of the issue, but the second issue is that we rely on the correct props being resolved in The obvious solution is adding a check to |
When you say "we rely" what do you mean exactly? Rely in what way?
I don't understand how this could be possible. If the component is lazy, we don't have its default props at first, do we? We're waiting for it to load. |
I'll continue this in #14108 |
Default props are resolved in
The initial load happens inside react/packages/react-reconciler/src/ReactFiberBeginWork.js Lines 769 to 774 in d5d10d1
It was still broken for the initial commit phase, as props get read from the Even then, it's still broken for updates. In My conclusion was that, at some point in the update path, we'd need to check the I was thinking it would be a similar solution to how we handle props with fragments react/packages/react-reconciler/src/ReactChildFiber.js Lines 1128 to 1130 in d5d10d1
|
Would |
(Feel free to push to my branch in #14108) |
We could check |
A (still) failing test and naive "fix" for #13960. I want to dig into this more, but hopefully I can get some input on the right approach for this.