-
-
Notifications
You must be signed in to change notification settings - Fork 8.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
feat: introduce suspensible option to <Suspense> to fix suspense flicks #6736
Conversation
Co-authored-by: Damian Głowala <48835293+DamianGlowala@users.noreply.github.com>
Can we get this merged soon? |
Hey @DamianGlowala , is there any reason why this isn't merged yet? Thank you! |
From the message I received from @antfu, this PR needs feedback from the core team. There isn't any timescale for having this merged at the moment. For Nuxt users: if this PR takes longer than expected, it might be patched directly in Nuxt at some point. |
Can we get this merged soon? |
@yyx990803 any chances to review this PR and consider including it in v3.3.0 release should there be no blocking issues? 🙏 |
Resolve #5513
This PR introduces a new prop for
Suspense
-<Suspense suspensible>
to allow nested suspense to be captured by the parent suspense.Reproduction
Thanks a lot to @danielroe for the great reproduction:
https://stackblitz.com/edit/vitejs-vite-ftc8df?file=src%2FApp.vue
The Problem
When we have multiple async components like:
Suspense
creates a boundary that will resolve all the async components down the tree, which is how it is expected to be.When both async components need to be async (nested route page for example)
At the initial mount, it works as expected, both
DynamicAsyncOuter
andDynamicAsyncInner
are waited before rendering.The problem comes with patching. When we change
DynamicAsyncOuter
, Suspense awaits it correctly, but when we changeDynamicAsyncInner
, the Suspense does not get patched causing the nestedDynamicAsyncInner
renders an empty node until it has been resolved, causing the flickering.In order to solve that, we could have a nested suspense to handle the patch for the nested component, like:
This solves the patching issue but makes the mounting break as the nested Suspense now behaves like a sync component and has its own fallback.
The Solution
This PR introduces a new prop for
Suspense
-<Suspense suspensible>
to allow nested suspense to be captured by the parent suspense. Making it able to handle async patching for branches and keep the mount as one render to avoid flickering.Unlike async components,
Suspsense
'ssuspensible
prop is the default to false in order to not break the current behavior.