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

Suspense vs Traditional Loading States

Comparing manual isLoading flags with Suspense: less boilerplate, better composition, but different mental model.

Suspense vs Traditional Loading States

What you'll learn: How Suspense compares to manual isLoading flags and why it reduces boilerplate while requiring a shift in thinking.

The Traditional Approach

Historically, you've managed loading states imperatively: create a boolean like isLoading, set it to true before fetching, then false when data arrives. You manually wire up conditional rendering everywhere:

const [data, setData] = useState(null);
const [isLoading, setIsLoading] = useState(true);

useEffect(() => {
  setIsLoading(true);
  fetchData().then(result => {
    setData(result);
    setIsLoading(false);
  });
}, []);

if (isLoading) return <Spinner />;
return <Content data={data} />;

Every component repeats this pattern. You track loading, error, and data states manually.

The Suspense Approach

Suspense flips the model: you don't manage loading state. Your component just tries to read data. If it's not ready, React automatically shows the nearest Suspense boundary's fallback:

// No isLoading state!
const data = resource.read(); // throws Promise if not ready
return <Content data={data} />;

The Suspense boundary handles the loading UI declaratively, miles away in your component tree.

Key Differences

Less boilerplate: No useState, no useEffect cleanup, no if (isLoading) checks scattered everywhere.

Better composition: One Suspense boundary can coordinate loading states for multiple child components automatically.

Different mental model: You're no longer imperatively controlling flow. You declare "show spinner until children are ready" and let React orchestrate. It feels foreign at first—you're trusting the framework to handle what you used to control explicitly.

Trade-off: Requires rethinking data fetching. Traditional async/await in useEffect doesn't trigger Suspense—you need libraries or patterns that throw Promises during render.

Key Takeaway: Suspense replaces imperative isLoading flags with declarative boundaries, eliminating boilerplate and enabling better composition, but demands adopting a "read-and-throw" pattern that feels different from traditional React state management.