0
Challenge · 36Hooks & Effects
Suspense
Performanceused in ~60% of apps
Loading states are everywhere, and hand-rolling an isLoading boolean for each one clutters every component. Suspense lets you declare a single loading UI for a whole region — React shows it automatically while anything inside is still getting ready, then swaps in the real content.
Core idea. <Suspense fallback={<Spinner/>}> wraps part of your tree and renders the fallback while its children are suspending (lazy code or Suspense-enabled data that isn't ready yet), then automatically reveals the real children once everything inside is ready.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
Where do the Suspense boundaries go?
<Suspense fallback={<Spinner/>}><PanelA /></Suspense>
<Suspense fallback={<Spinner/>}><PanelB /></Suspense>
<Header />static — never suspends
Suspense
<PanelA />fast data
loaded
Suspense
<PanelB />slow data
loaded
One boundary per panel = independent reveals. Each panel shows its own spinner and pops in the moment it is ready — the slow panel no longer holds the fast one hostage. The header sits outside both boundaries, so it never disappears.
↑ play a little first, then dig in