Skip to content

Commit efaa3e5

Browse files
[Suspense] Document what activates a boundary, with live examples (#8505)
* [Suspense] Add 'What activates a Suspense boundary' section * [Suspense] Clarify image activation wording (review feedback) * Define "suspense-enabled-framework" * Update outdated framework-less data fetching note to reference use() * fix: clarify Suspense boundary activation and fallback behavior * Add code example * update styling * Cleanup caveat * add link to blogpost * Replace notes with link to suspense docs * Tweak caveat * Update caveat to clarify streaming behavior during server rendering * Address feedback * address feedback * Clarify documentation on Suspense-enabled frameworks * Update links and wording * Improve example * Clarify heading for Suspense-enabled frameworks section * Restructure page * Update to be docs compliant and clarify images * Address review feedback * Add more suspense examples * Add more examples * Clarify image loading behavior during <ViewTransition> updates in Suspense documentation * Enhance Suspense documentation with additional details on font and image loading during <ViewTransition> updates * Update * Enhance Suspense documentation with examples of stylesheet loading behavior and vanilla DOM comparison * agent review
1 parent c3c956b commit efaa3e5

9 files changed

Lines changed: 992 additions & 75 deletions

File tree

src/content/reference/react-dom/server/renderToPipeableStream.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,17 +284,7 @@ Streaming does not need to wait for React itself to load in the browser, or for
284284
285285
<Note>
286286
287-
**Only Suspense-enabled data sources will activate the Suspense component.** They include:
288-
289-
- Data fetching with Suspense-enabled frameworks like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) and [Next.js](https://nextjs.org/docs/getting-started/react-essentials)
290-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
291-
- Reading the value of a Promise with [`use`](/reference/react/use)
292-
293-
Suspense **does not** detect when data is fetched inside an Effect or event handler.
294-
295-
The exact way you would load data in the `Posts` component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
296-
297-
Suspense-enabled data fetching without the use of an opinionated framework is not yet supported. The requirements for implementing a Suspense-enabled data source are unstable and undocumented. An official API for integrating data sources with Suspense will be released in a future version of React.
287+
Only data read from a source that [activates a Suspense boundary](/reference/react/Suspense#what-activates-a-suspense-boundary), such as a Promise read with [`use`](/reference/react/use), will suspend during rendering. Suspense does not detect data fetched inside an Effect or event handler.
298288
299289
</Note>
300290

src/content/reference/react-dom/server/renderToReadableStream.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,17 +283,7 @@ Streaming does not need to wait for React itself to load in the browser, or for
283283
284284
<Note>
285285
286-
**Only Suspense-enabled data sources will activate the Suspense component.** They include:
287-
288-
- Data fetching with Suspense-enabled frameworks like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) and [Next.js](https://nextjs.org/docs/getting-started/react-essentials)
289-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
290-
- Reading the value of a Promise with [`use`](/reference/react/use)
291-
292-
Suspense **does not** detect when data is fetched inside an Effect or event handler.
293-
294-
The exact way you would load data in the `Posts` component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
295-
296-
Suspense-enabled data fetching without the use of an opinionated framework is not yet supported. The requirements for implementing a Suspense-enabled data source are unstable and undocumented. An official API for integrating data sources with Suspense will be released in a future version of React.
286+
Only data read from a source that [activates a Suspense boundary](/reference/react/Suspense#what-activates-a-suspense-boundary), such as a Promise read with [`use`](/reference/react/use), will suspend during rendering. Suspense does not detect data fetched inside an Effect or event handler.
297287
298288
</Note>
299289

src/content/reference/react-dom/static/prerender.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,7 @@ Imagine that `<Posts />` needs to load some data, which takes some time. Ideally
275275
276276
<Note>
277277
278-
**Only Suspense-enabled data sources will activate the Suspense component.** They include:
279-
280-
- Data fetching with Suspense-enabled frameworks like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) and [Next.js](https://nextjs.org/docs/getting-started/react-essentials)
281-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
282-
- Reading the value of a Promise with [`use`](/reference/react/use)
283-
284-
Suspense **does not** detect when data is fetched inside an Effect or event handler.
285-
286-
The exact way you would load data in the `Posts` component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
287-
288-
Suspense-enabled data fetching without the use of an opinionated framework is not yet supported. The requirements for implementing a Suspense-enabled data source are unstable and undocumented. An official API for integrating data sources with Suspense will be released in a future version of React.
278+
Only data read from a source that [activates a Suspense boundary](/reference/react/Suspense#what-activates-a-suspense-boundary), such as a Promise read with [`use`](/reference/react/use), will suspend during rendering. Suspense does not detect data fetched inside an Effect or event handler.
289279
290280
</Note>
291281

src/content/reference/react-dom/static/prerenderToNodeStream.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,7 @@ Imagine that `<Posts />` needs to load some data, which takes some time. Ideally
276276
277277
<Note>
278278
279-
**Only Suspense-enabled data sources will activate the Suspense component.** They include:
280-
281-
- Data fetching with Suspense-enabled frameworks like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) and [Next.js](https://nextjs.org/docs/getting-started/react-essentials)
282-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
283-
- Reading the value of a Promise with [`use`](/reference/react/use)
284-
285-
Suspense **does not** detect when data is fetched inside an Effect or event handler.
286-
287-
The exact way you would load data in the `Posts` component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
288-
289-
Suspense-enabled data fetching without the use of an opinionated framework is not yet supported. The requirements for implementing a Suspense-enabled data source are unstable and undocumented. An official API for integrating data sources with Suspense will be released in a future version of React.
279+
Only data read from a source that [activates a Suspense boundary](/reference/react/Suspense#what-activates-a-suspense-boundary), such as a Promise read with [`use`](/reference/react/use), will suspend during rendering. Suspense does not detect data fetched inside an Effect or event handler.
290280
291281
</Note>
292282

src/content/reference/react/Activity.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -755,17 +755,7 @@ Pre-rendering components with hidden Activity boundaries is a powerful way to re
755755

756756
<Note>
757757

758-
**Only Suspense-enabled data sources will be fetched during pre-rendering.** They include:
759-
760-
- Data fetching with Suspense-enabled frameworks like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) and [Next.js](https://nextjs.org/docs/app/building-your-application/routing/loading-ui-and-streaming#streaming-with-suspense)
761-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
762-
- Reading the value of a cached Promise with [`use`](/reference/react/use)
763-
764-
Activity **does not** detect data that is fetched inside an Effect.
765-
766-
The exact way you would load data in the `Posts` component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
767-
768-
Suspense-enabled data fetching without the use of an opinionated framework is not yet supported. The requirements for implementing a Suspense-enabled data source are unstable and undocumented. An official API for integrating data sources with Suspense will be released in a future version of React.
758+
Only data read from a source that [activates a Suspense boundary](/reference/react/Suspense#what-activates-a-suspense-boundary), such as a Promise read with [`use`](/reference/react/use), is fetched during pre-rendering. Activity does not detect data fetched inside an Effect.
769759

770760
</Note>
771761

0 commit comments

Comments
 (0)