liveBook · Manning

SuspenseList

As explained in React Hooks in Action: With Suspense and Concurrent Mode

SuspenseList is a React component that coordinates the reveal order and fallback display of multiple Suspense boundaries.

SuspenseList coordinates several Suspense boundaries so loading fallbacks appear in a deliberate order instead of shifting the page unpredictably. It is useful when independent data sources, such as bookings and to-dos, resolve at different times. section 13.2 section 13.2.1

Reveal bookings before to-dos

Wrap the boundaries and choose a reveal order:\n\n<SuspenseList revealOrder="forwards">\n <Suspense fallback={<p>Loading user bookings...</p>}>\n <UserBookings id={userID}/>\n </Suspense>\n <Suspense fallback={<p>Loading user todos...</p>}>\n <UserTodos id={userID}/>\n </Suspense>\n</SuspenseList>\n\nWith forwards, bookings appear before to-dos even when the to-dos load first. section 13.2.2

Choose the fallback orchestration that matches the intended user experience:

  • Set revealOrder="forwards" to reveal boundaries from top to bottom. section 13.2.2
  • Set revealOrder="backwards" to reveal later boundaries first, or "together" to reveal them at the same time. section 13.2.2
  • Set tail="collapsed" to show only one fallback at a time, displaying the next fallback after the preceding boundary renders. section 13.2.2
Listing 13.8 Wrap the two Suspense components in a SuspenseList
<SuspenseList                       #1
  revealOrder="forwards"            #2
>
  <Suspense fallback={<p>Loading user bookings...</p>}>
    <UserBookings id={userID}/>
  </Suspense>
 
  <Suspense fallback={<p>Loading user todos...</p>}>
    <UserTodos id={userID}/>
  </Suspense>
</SuspenseList>
#1 Wrap the Suspense components in a SuspenseList.
#2 Specify the revealOrder.

Inspect the focused JSX listing that wraps two Suspense boundaries in SuspenseList and sets revealOrder. section 13.2.2

How React Hooks in Action: With Suspense and Concurrent Mode covers it

How deep it goes
Demonstrates JSX composition, revealOrder options, and collapsed tails, while deferring stable API details because the component remains experimental.
Examples
Uses a Users page whose UserDetails panel loads bookings and to-dos through separate Suspense boundaries.
What it assumes
Assumes familiarity with React components and Suspense, while demonstrating the problem of independently resolving data from zero.
What you can do after
Apply via React to order Suspense reveals and limit visible fallbacks during asynchronous UI updates.
How it connects
Connects Suspense boundaries with fallbacks, reveal order, loading states, and Concurrent Mode.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of React Hooks in Action: With Suspense and Concurrent Mode. The section links point to the parts of the book it draws on.