Suspense is often described as a loading spinner component, which undersells it and leads directly to the bugs people blame on the library. What actually happens is that a component asks for data it does not have yet, throws a signal upward, and lets the nearest enclosing boundary render its fallback instead. The subtree below that boundary is not partially rendered, not half-updated and not showing stale values: it is simply not committed until the data arrives. That guarantee is what makes loading states consistent across a screen rather than a scatter of independent spinners each appearing at its own moment.
đĄBoundaries are layout decisions
Where you place a Suspense boundary decides how much of the interface waits together. Put one around the whole page and a single slow query blanks everything. Put one around each region and the header, navigation and fast content paint immediately while the slow table fills in.
What suspending actually means
When a component suspends, React does not commit it. The boundary above renders the fallback, and React keeps listening for the promise that caused the suspension. When it resolves, React retries rendering, and this time the data is available, so the real subtree is committed and the fallback is removed. Nothing in the interim is a lie: the fallback is the committed output until the content is ready.
The implication that catches people out is that a component must be ready to render twice, and neither render may show partial data. A component that awaits one query in the body and a second one further down suspends twice, which produces a fallback flash the moment the second promise starts. Resolve what you need before rendering, or place a boundary at the point where the second wait begins. React does not keep the first render around for you, so anything the component needs must arrive through the same suspense path.
The boundary contract
The contract has three parts: a fallback that reserves the right amount of space, a boundary placed as close as possible to the component that actually waits, and an error boundary wrapping the pair so a rejected promise degrades into a message rather than a white screen.
import { Suspense, use, useState, useEffect } from 'react';
const userCache = new Map();
function loadUser(id) {
if (!userCache.has(id)) {
userCache.set(
id,
fetch(`/api/users/${id}`)
.then((r) => {
if (!r.ok) throw new Error(`User ${id} could not be loaded`);
return r.json();
})
.finally(() => {
setTimeout(() => userCache.delete(id), 30_000);
})
);
}
return userCache.get(id);
}
function UserName({ userId }) {
const user = use(loadUser(userId));
return <span>{user.name}</span>;
}
export function TeamRoster({ ids }) {
return (
<ul className="roster">
{ids.map((id) => (
<li key={id}>
<Suspense fallback={<span className="name-skeleton" aria-hidden="true" />}>
<UserName userId={id} />
</Suspense>
</li>
))}
</ul>
);
}
Each list item owns its own boundary, so one slow profile does not hold up the other nine, and because every fallback is the same width as a name, the row heights never jump. Caching the promise rather than the result is what makes suspense work with plain fetch: the second render of the same component finds an already-resolving promise instead of starting a new request.
Independent regions, independent skeletons
A dashboard is the clearest demonstration. Statistics, a chart and a table usually query different endpoints with very different latencies. Giving each its own boundary produces a page where the numbers appear at once, the chart follows, and the table arrives last, with the reader able to start reading rather than watching a single spinner for the slowest of the three.
import { Suspense } from 'react';
import ErrorBoundary from './ErrorBoundary';
function Region({ label, fallback, children }) {
return (
<section aria-label={label} className="region">
<ErrorBoundary fallback={<p role="alert">This section failed to load.</p>}>
<Suspense fallback={fallback}>{children}</Suspense>
</ErrorBoundary>
</section>
);
}
export function Dashboard() {
return (
<div className="dashboard">
<Region label="Key metrics" fallback={<StatsSkeleton />}>
<KeyStats />
</Region>
<Region label="Traffic chart" fallback={<ChartSkeleton />}>
<TrafficChart />
</Region>
<Region label="Recent orders" fallback={<TableSkeleton rows={6} />}>
<RecentOrders />
</Region>
</div>
);
}
Wrapping the error boundary around the suspense boundary rather than inside it is deliberate. An error thrown while rendering the real content must be caught by something that is already mounted, and the fallback boundary is the element that persists across the swap. Putting the error boundary inside means it unmounts with the content it is supposed to protect.
Where each data source fits
Suspense works with several data sources, and each has its own conventions for caching, deduplication and invalidation.
| Data source | Caching | Deduplication | Invalidation | Notes |
|---|---|---|---|---|
| Framework data fetching | Per route and per request | Automatic within a render pass | Revalidate on navigation or timer | Simplest default for server data |
| Client cache library | Normalized, shared across components | Automatic by query key | Refetch on focus or mutation | Best when views overlap heavily |
| Plain fetch with a promise cache | Your Map or a library | Only if you cache the promise yourself | Explicit delete after a timeout | Works, but you own every detail |
| Image and font loading | Browser cache | Suspense-friendly wrappers exist | Normal HTTP rules | Keeps first paint stable |
Whichever you choose, the rule is the same: cache the promise, not the value, because two components rendering in the same pass must share one in-flight request rather than issuing duplicates.
Pairing Suspense with error handling
A rejected promise inside a suspended component behaves like an error, not like data, so it must be caught by an error boundary. Without one, the boundary's fallback stays on screen indefinitely while the failure is only visible in the console, which is the single most common production report about Suspense.
Error boundaries cannot catch errors thrown in event handlers, asynchronous callbacks or during server rendering, so a fetch failure that happens outside render is still your responsibility: attach a rejection handler, surface the failure in state, and offer a retry that clears the cached promise. A retry mechanism matters more than usual here, because a cached rejected promise would otherwise make every subsequent render fail even after the server has recovered.
Failure modes you will meet in production
Three patterns account for most incidents. The first is a boundary placed too high, so the entire page waits on the slowest query; the fix is to move boundaries down to each region. The second is a fallback that does not reserve space, producing layout shift when content arrives; the fix is a skeleton with the dimensions of the real element. The third is a missing error boundary, so a network failure leaves a permanent loading state; the fix is wrapping every boundary pair and making sure the cached promise is cleared on retry.
A fourth, quieter failure is showing stale content without acknowledging it. If a region refreshes in the background and you keep the old data mounted, that is a reasonable choice, but mark the region as busy so the reader knows an update is in flight rather than assuming the numbers are final. None of these require a different library, only the discipline of placing one boundary, one sized fallback and one error boundary around each part of the screen that can arrive on its own schedule.
Common Mistakes
Placing one boundary around the entire page so the slowest query blocks everything
Fix: Give each independent region its own boundary so fast content renders while slow content loads.
Rendering a spinner with no reserved space above a tall table
Fix: Size the fallback to the final content so the swap does not move the page under the reader.
Wrapping the error boundary inside the suspense boundary
Fix: Put the error boundary outside so it survives the swap and can catch failures thrown while rendering content.
Caching the resolved value instead of the in-flight promise
Fix: Cache promises so components rendered in the same pass share one request instead of issuing duplicates.
Key Takeaways
- Suspending prevents a subtree from committing until its data exists, which is why loading states stay consistent
- Boundary placement is a layout decision: one per region keeps fast content visible while slow content loads
- Wrap the suspense boundary in an error boundary so a rejected promise degrades into a message instead of a permanent spinner
- Cache the promise rather than the result so concurrent renders share a single request
- Skeletons must reserve the final space, and background refreshes should mark the region as busy
Extended Learning: Beyond the Basics
Key Concepts Summary
This lesson covers fundamental concepts that serve as building blocks for more advanced topics. Master these basics before moving to intermediate and advanced material.
Prerequisite Knowledge
Before studying this topic in depth, ensure you understand:
- Basic definitions and terminology
- Core formulas and their derivations
- Common applications in real-world scenarios
- Typical pitfalls and misconceptions
Step-by-Step Walkthrough
Let us work through a complete example to solidify understanding:
Step 1: Identify the problem type. Determine which category this problem falls into and which approach is most appropriate.
Step 2: Apply the relevant formula. Substitute known values into the appropriate equation, paying attention to units and constraints.
Step 3: Simplify and solve. Work through the algebra step by step, checking each intermediate result.
Step 4: Verify the answer. Check that the solution satisfies the original conditions and makes logical sense.
Common Mistakes to Avoid
- Misidentifying the problem type â Always start by categorizing the problem
- Incorrect formula application â Verify the formula applies to your specific case
- Unit errors â Always check units are consistent throughout
- Sign errors â Pay careful attention to positive and negative values
- Rounding too early â Keep full precision until the final answer
- Forgetting constraints â Check that solutions satisfy all given conditions
Real-World Applications
Understanding this concept is essential for:
- Advanced problem solving in examinations
- Building intuition for more complex topics
- Developing analytical thinking skills
- Applying mathematical reasoning to practical situations
Practice Exercises
- Basic: Solve 5 problems of increasing difficulty using the core concept.
- Intermediate: Apply the concept to word problems with multiple steps.
- Advanced: Combine this concept with 2-3 other topics in a comprehensive problem.
- Challenge: Create your own problem that requires this concept plus additional knowledge.
Interview and Exam Tips
- Common question patterns: Identify which exam or interview formats test this topic
- Time management: Practice completing problems within time constraints
- Common traps: Know the typical mistakes examiners set as distractors
- Verification strategy: Develop a quick method to check your answer
Related Topics
- Previous Topic â Build on the foundation laid here
- Next Topic â See how this concept extends to more advanced material
- Practice Problems â Additional exercises with solutions
- Video Explanation â Visual walkthrough of key concepts
Quick Reference Card
| Concept | Formula/Rule | Key Insight | Common Use |
|---|---|---|---|
| Core Definition | See main text | Understand the intuition | Foundation for all applications |
| Key Formula | See main text | Memorize the derivation | Direct problem solving |
| Special Case | See main text | Recognize when it applies | Simplifies complex problems |
| Edge Case | See main text | Know the limitations | Avoids errors |
Further Reading
For students who want to go deeper:
- Standard textbooks on the subject
- Research papers applying this concept
- Online courses with video explanations
- Practice problem collections with detailed solutions