Multiple Lazy Components in One Suspense
You'll learn how Suspense waits for all nested lazy components before showing content, and when to split into multiple boundaries instead.
How Suspense Handles Multiple Lazy Components
When you place multiple lazy components inside a single Suspense boundary, React waits for all of them to finish loading before hiding the fallback and revealing the content. It's like waiting for all passengers to board a bus before closing the doors — nobody shows up early.
<Suspense fallback={<Spinner />}>
<LazyHeader />
<LazyContent />
<LazyFooter />
</Suspense>
In this example, the spinner stays visible until LazyHeader, LazyContent, and LazyFooter have all loaded. React doesn't reveal the header first, then content, then footer — it's all or nothing within that boundary.
When This Pattern Works
This works well when components are logically connected and should appear together. Imagine a dashboard with three lazy-loaded charts that all belong to the same view — users expect to see them together, not popping in one by one.
When to Use Multiple Boundaries Instead
If components are independent or load at very different speeds, use separate Suspense boundaries:
<Suspense fallback={<HeaderSkeleton />}>
<LazyHeader />
</Suspense>
<Suspense fallback={<ContentSkeleton />}>
<LazyContent />
</Suspense>
Now the header can appear immediately when ready, even if content takes longer. This prevents fast-loading components from being "held hostage" by slower ones.
The Tradeoff
One boundary = simpler loading state, but slower perceived performance. Multiple boundaries = faster incremental rendering, but more visual complexity as things pop in.
Key Takeaway: A single Suspense boundary waits for all nested lazy components to load before rendering any of them; use multiple boundaries when components are independent and you want progressive reveal.