-
Notifications
You must be signed in to change notification settings - Fork 49.3k
Hide/unhide the content of dehydrated suspense boundaries if they resuspend #32900
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
Conversation
|
||
expect(ref.current).toBe(null); | ||
expect(span.style.display).toBe('none'); | ||
expect(textNode.nodeValue).toBe(''); |
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.
What used to happen is that these weren't hidden. They remained visible.
} | ||
|
||
function App({text, resuspend}) { | ||
const memoized = React.useMemo(() => <Component text={text} />, [text]); |
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.
Memoization is important because otherwise the change in props due to the update can force a hydration.
8ef4af1
to
006e201
Compare
006e201
to
95e060f
Compare
if (node.nodeType === ELEMENT_NODE) { | ||
const instance = ((node: any): HTMLElement & {_stashedDisplay?: string}); | ||
if (isHidden) { | ||
instance._stashedDisplay = instance.style.display; |
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.
We don't have the original props here yet since we haven't hydrated so we don't know what value to restore it to. So we stash the old value on an expando when we hide it. This is unfortunate but also it's just an edge case.
95e060f
to
f661d4f
Compare
f661d4f
to
ae9c0fd
Compare
Comparing: 539bbdb...ae9c0fd Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show |
A possible alternative would be maybe to try to clear the boundary as if we're unable to hydrate it but we're not actually unable to hydrate content that was just temporarily hidden even though we might be unable to before it unsuspends. |
I think this is probably the right semantics if you also account for having to do a view transition on the dehydrated content. |
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.
sgtm but up to you if it's worth fixing
…uspend (#32900) Found this bug while working on Activity. There's a weird edge case when a dehydrated Suspense boundary is a direct child of another Suspense boundary which is hydrated but then it resuspends without forcing the inner one to hydrate/delete. It used to just leave that in place because hiding/unhiding didn't deal with dehydrated fragments. Not sure this is really worth fixing. DiffTrain build for [ebf7318](ebf7318)
…uspend (#32900) Found this bug while working on Activity. There's a weird edge case when a dehydrated Suspense boundary is a direct child of another Suspense boundary which is hydrated but then it resuspends without forcing the inner one to hydrate/delete. It used to just leave that in place because hiding/unhiding didn't deal with dehydrated fragments. Not sure this is really worth fixing. DiffTrain build for [ebf7318](ebf7318)
Stacked on #32851 and #32900. This implements the equivalent Configs for ActivityInstance as we have for SuspenseInstance. These can be implemented as comments but they don't have to be and can be implemented differently in the renderer. This seems like a lot duplication but it's actually ends mostly just calling the same methods underneath and the wrappers compiles out. This doesn't leave the Activity dehydrated yet. It just hydrates into it immediately.
Stacked on #32851 and #32900. This implements the equivalent Configs for ActivityInstance as we have for SuspenseInstance. These can be implemented as comments but they don't have to be and can be implemented differently in the renderer. This seems like a lot duplication but it's actually ends mostly just calling the same methods underneath and the wrappers compiles out. This doesn't leave the Activity dehydrated yet. It just hydrates into it immediately. DiffTrain build for [17f88c8](17f88c8)
Stacked on #32851 and #32900. This implements the equivalent Configs for ActivityInstance as we have for SuspenseInstance. These can be implemented as comments but they don't have to be and can be implemented differently in the renderer. This seems like a lot duplication but it's actually ends mostly just calling the same methods underneath and the wrappers compiles out. This doesn't leave the Activity dehydrated yet. It just hydrates into it immediately. DiffTrain build for [17f88c8](17f88c8)
Stacked on facebook#32851 and facebook#32900. This implements the equivalent Configs for ActivityInstance as we have for SuspenseInstance. These can be implemented as comments but they don't have to be and can be implemented differently in the renderer. This seems like a lot duplication but it's actually ends mostly just calling the same methods underneath and the wrappers compiles out. This doesn't leave the Activity dehydrated yet. It just hydrates into it immediately. DiffTrain build for [17f88c8](facebook@17f88c8)
Stacked on facebook#32851 and facebook#32900. This implements the equivalent Configs for ActivityInstance as we have for SuspenseInstance. These can be implemented as comments but they don't have to be and can be implemented differently in the renderer. This seems like a lot duplication but it's actually ends mostly just calling the same methods underneath and the wrappers compiles out. This doesn't leave the Activity dehydrated yet. It just hydrates into it immediately. DiffTrain build for [17f88c8](facebook@17f88c8)
Found this bug while working on Activity. There's a weird edge case when a dehydrated Suspense boundary is a direct child of another Suspense boundary which is hydrated but then it resuspends without forcing the inner one to hydrate/delete.
It used to just leave that in place because hiding/unhiding didn't deal with dehydrated fragments.
Not sure this is really worth fixing.