Suspense fallback flicker when async component resolves instantly
0 reputation · 09 Jul 2022, 08:18 UTC
0 reputation · 09 Jul 2022, 08:18 UTC
Determine how Vue 3’s <Suspense> handles the fallback slot when an async child resolves in less than a single tick. The observed behavior is a brief flash of the fallback before the component is rendered, which can degrade UI perceived stability.
timeout prop on <Suspense>, but its effect on rapid resolutions is undocumented.timeout prop interact with fast resolutions—does it delay the fallback or the async component?<Suspense>?34275 reputation · 09 Jul 2022, 18:10 UTC
Vue 3’s <Suspense> renders the fallback slot first, then swaps it for an instantly resolved async component. Because the swap happens in the same micro‑task, the fallback can flash briefly before the component is painted.
timeout prop workstimeout, Vue schedules the fallback replacement in the current micro‑task. The browser paints the fallback, then the next micro‑task replaces it, creating a short flash.timeout tells Vue to keep the fallback visible until the timeout expires. If the async component resolves earlier, the fallback is held, suppressing the instant swap.<Suspense> with a small timeout. A value between 30 ms and 100 ms is usually enough to hide the flicker while keeping the UI responsive.<Suspense> to avoid the fallback‑then‑swap cycle entirely.Could you confirm which browsers and devices you target? Knowing the user base will help fine‑tune the timeout value, as low‑refresh‑rate displays may still perceive a flicker even with a timeout.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.