Course contentsShow
← React
Lesson 1353 of 2,39634. Suspense FundamentalsFree lesson

Multiple Lazy Components Under One Boundary

Learn how multiple lazy components share a single Suspense boundary and loading state.

Multiple Lazy Components Under One Boundary

What you'll learn: How a single Suspense boundary can handle loading states for multiple lazy-loaded components at once.

The Core Concept

When you have several React.lazy() components rendering within the same Suspense boundary, React treats them as a group. If any of those lazy components isn't loaded yet, the entire boundary shows its fallback UI. Once all components are ready, they all appear together.

Think of it like waiting for a group photo: everyone needs to be present before the photographer takes the picture. One person missing? The whole group waits.

How It Works

const Dashboard = React.lazy(() => import('./Dashboard'));
const Sidebar = React.lazy(() => import('./Sidebar'));
const Footer = React.lazy(() => import('./Footer'));

function App() {
  return (
    <Suspense fallback={<div>Loading entire layout...</div>}>
      <Dashboard />
      <Sidebar />
      <Footer />
    </Suspense>
  );
}

In this example, the fallback displays until all three components—Dashboard, Sidebar, and Footer—have loaded. React waits for the slowest one before revealing any of them.

Why This Matters

This "all-or-nothing" behavior prevents layout thrashing—where components pop in one at a time, causing jarring visual shifts. It creates a smoother user experience by coordinating the appearance of related UI pieces.

However, be mindful: if one component is much slower to load, it delays the entire group. Sometimes splitting into multiple Suspense boundaries (which you've already learned) gives better control.

Key Takeaway: Multiple lazy components under one Suspense boundary share a single loading state—none render until all are ready, creating coordinated loading behavior.