Skip to content

Commit 567cdd4

Browse files
committed
Restructure page
1 parent 2dfe10f commit 567cdd4

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

src/content/reference/react/Suspense.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,30 @@ title: <Suspense>
3838

3939
---
4040

41+
### What activates a Suspense boundary {/*what-activates-a-suspense-boundary*/}
42+
43+
A Suspense boundary waits for its content to be ready before revealing it. Any of the following blocks a boundary's content from being revealed:
44+
45+
- Lazy-loading component code with [`lazy`](/reference/react/lazy).
46+
- Reading a Promise with [`use`](/reference/react/use), including data streamed from [Server Components](/reference/rsc/server-components) or provided by a [Suspense-enabled framework](#suspense-enabled-frameworks).
47+
- Loading a stylesheet rendered with [`<link rel="stylesheet">` and a `precedence` prop.](/reference/react-dom/components/link#special-rendering-behavior) React blocks the boundary until the stylesheet loads, up to a timeout.
48+
- Loading fonts. When a boundary is revealed by streamed SSR content, React waits for [`document.fonts.ready`](https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/ready) before showing it, up to a timeout, so text doesn't flash with a fallback font. Fonts also block a [`<ViewTransition>`](/reference/react/ViewTransition) update.
49+
- Streaming a large boundary's HTML during server rendering. React reveals the content as the HTML arrives.
50+
- Loading an image, where the `src` blocks the boundary until the image loads. This behavior is not enabled by default. When enabled, an `onLoad` handler opts an image out, and images in a [`<ViewTransition>`](/reference/react/ViewTransition) update opt in automatically.
51+
- <ExperimentalBadge /> Performing CPU-bound render work inside a `<Suspense>` boundary marked with the `defer` prop.
52+
53+
<Note>
54+
55+
#### Suspense-enabled frameworks {/*suspense-enabled-frameworks*/}
56+
57+
A *Suspense-enabled framework* gives you a way to read data in your component that calls [`use`](/reference/react/use) under the hood, so reading that data activates the nearest boundary. The exact way you load your data depends on your framework, and you'll find the details in its documentation.
58+
59+
Without a framework, you can read a Promise with `use` directly, as long as the Promise is [cached so the same instance is reused across renders.](/reference/react/use#caching-promises-for-client-components)
60+
61+
</Note>
62+
63+
---
64+
4165
## Usage {/*usage*/}
4266

4367
### Displaying a fallback while content is loading {/*displaying-a-fallback-while-content-is-loading*/}
@@ -205,32 +229,8 @@ async function getAlbums() {
205229

206230
</Sandpack>
207231

208-
---
209-
210-
### What activates a Suspense boundary {/*what-activates-a-suspense-boundary*/}
211-
212-
A Suspense boundary waits for its content to be ready before revealing it. Any of the following blocks a boundary's content from being revealed:
213-
214-
- Lazy-loading component code with [`lazy`](/reference/react/lazy).
215-
- Reading a Promise with [`use`](/reference/react/use), including data streamed from [Server Components](/reference/rsc/server-components).
216-
- Data fetching through a [Suspense-enabled framework](#suspense-enabled-frameworks) like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/), which integrates its own data source with Suspense.
217-
- Loading a stylesheet rendered with [`<link rel="stylesheet">` and a `precedence` prop.](/reference/react-dom/components/link#special-rendering-behavior) React blocks the boundary until the stylesheet loads, up to a timeout.
218-
- Loading fonts. When a boundary is revealed by streamed SSR content, React waits for [`document.fonts.ready`](https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/ready) before showing it, up to a timeout, so text doesn't flash with a fallback font. Fonts also block a [`<ViewTransition>`](/reference/react/ViewTransition) update.
219-
- Streaming a large boundary's HTML during server rendering. React reveals the content as the HTML arrives.
220-
- Loading an image, where the `src` blocks the boundary until the image loads. This behavior is not enabled by default. When enabled, an `onLoad` handler opts an image out, and images in a [`<ViewTransition>`](/reference/react/ViewTransition) update opt in automatically.
221-
- <ExperimentalBadge /> Performing CPU-bound render work inside a `<Suspense>` boundary marked with the `defer` prop.
222-
223-
<Note>
224-
225-
#### Suspense-enabled frameworks {/*suspense-enabled-frameworks*/}
226-
227-
A *Suspense-enabled framework* integrates its data fetching with Suspense, so that reading data in a component activates the nearest boundary. Some frameworks build on Server Components and [`use`](/reference/react/use), like Next.js, while others provide a custom integration, like Relay. The exact way you load your data depends on your framework, and you'll find the details in its documentation.
228-
229-
Without a framework, you can read a Promise with `use` directly, as long as the Promise is [cached so the same instance is reused across renders.](/reference/react/use#caching-promises-for-client-components)
230-
231-
</Note>
232+
By contrast, code that fetches data outside of `use`, such as inside an Effect, does not activate the boundary:
232233

233-
Fetching data inside an Effect does not activate the boundary. Suspense can't detect the fetch, so the `fallback` never appears and the list stays empty until the data arrives:
234234

235235
<Sandpack>
236236

0 commit comments

Comments
 (0)