Course contentsShow
← React
Lesson 643 of 2,39617. Common useEffect MistakesFree lesson

The Waterfall Problem

How client-side fetching creates sequential waterfalls: HTML loads, JS loads, then data loads—each waiting for the last.

The Waterfall Problem

You'll learn why client-side data fetching in React creates a slow, sequential loading chain that hurts user experience.

What's Happening Under the Hood

When you fetch data in useEffect, your app loads in three sequential stages:

  1. HTML loads — The browser receives an empty shell
  2. JavaScript loads — React code downloads and executes
  3. Data loads — Finally, your fetch() request fires

Each stage waits for the previous one to complete. This is the waterfall problem: requests cascade down like water over steps, instead of happening in parallel.

The Analogy

Imagine ordering coffee:

  • Old way (waterfall): You wait in line. Then you order. Then the barista makes your drink. Total: 15 minutes.
  • Better way: You call ahead while driving. Your coffee is ready when you arrive. Total: 5 minutes.

Client-side fetching is like the first scenario — everything happens in sequence.

Why This Matters

function Profile() {
  const [user, setUser] = useState(null);

  useEffect(() => {
    fetch('/api/user').then(r => r.json()).then(setUser);
  }, []);

  // ...
}

This code can't start fetching until after the JavaScript bundle downloads and React mounts the component. On slow connections, users stare at a blank screen for seconds.

With nested components that each fetch data, the waterfall deepens: parent fetches, renders, then child fetches.

Key Takeaway: Client-side useEffect fetching creates a sequential waterfall (HTML → JS → Data), where each step waits for the last, significantly slowing down your app's time-to-content.