Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 14.3 — Suspense
React · Example 1 of 3 React 19+

Nested boundaries and the reveal order

Header is ready at 300 ms but waits for Sidebar (600 ms): they share a boundary. The comments fallback only appears with them, and comments come last. Press Run again and watch the stages.

<Suspense fallback={...}> shows a fallback while anything inside it is still loading (lazy code, a promise read with use(), a Suspense-enabled library), lets you nest boundaries to control what appears together, and works with transitions to keep the old screen visible instead of flashing a spinner.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 6 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

A product page has Details (fast), Reviews (slow) and Recommendations (slowest). Write the JSX so details appear first, and reviews and recommendations each fill in independently.

02

Load a Settings panel with lazy only when a button is clicked, with a fallback that says Loading settings....

03

A SearchResults component suspends while results load. Make typing a new query keep the old results visible (dimmed) instead of showing the fallback.

Explain it without notes

01

What does Suspense do, and what kinds of things can make a component suspend?

02

How do nested Suspense boundaries control the reveal order? What happens to two components in the same boundary?

03

Why can a transition prevent a loading fallback from appearing, and when should you use one?

04

How does lazy work with Suspense?

Nested boundaries and the reveal order React 19+

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

shown: page fallback
shown: header
shown: sidebar
shown: comments fallback
shown: comments