-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Initialize children if they're null in suspense #2570
Conversation
Size Change: +16 B (0%) Total Size: 40 kB
ℹ️ View Unchanged
|
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.
Looked a little more into this, and it is failing because when doing a rerender from App
(which is what the setState
is doing) and not Suspense
, the vnode that is set by diff() on line 170 is a VNode that was created by App's render method. Because it come from App's render method, _children
is initialized to null
(that vnode hasn't passed through diffChildren
yet).
This works whenever the rerender starts with Suspense
because when Suspense starts the rerender, we copy all the properties of the oldVNode to the "newVNode", including _children. So when diff() line 170 runs in this case, it happens to assign c._vnode
to a vnode that has the old _children
property.
Still uncertain what the right fix here is though...
|
||
/** @type {() => Promise<void>} */ | ||
let resolve; | ||
const Lazy = lazy(() => { |
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.
If you want you could use the createLazy
helper to simplify this to const [Lazy, resolve] = createLazy()
and then pass LazyComp
into resolve
below
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.
Uh okay, just copy&pasted from another test. I'll check
Thanks for your comment, paired with a fresh mind it makes things a lot clearer. I changed the fix to just skip the restore of the EDIT: I guess we should check what the impact of this change is to the re-rendering behaviour of Suspenses‘ children and compare this to react. |
Might be useful to more deeply understand what purpose setting |
Honestly I am currently too tired to fully understand where the race condition happens but this fixes it. If somebody has the power to investigate a bit I'd be more than happy :) Otherwise I'd might look into this in the following days.
@developit you mentioned in one of the issues you have a branch fixing this locally. Could you double check this PR?
Fixes #2519
Fixes #2488