Skip to content

Commit be96926

Browse files
committed
Update suspense notes
1 parent 4d3d495 commit be96926

File tree

8 files changed

+16
-98
lines changed

8 files changed

+16
-98
lines changed

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -282,22 +282,6 @@ Streaming does not need to wait for React itself to load in the browser, or for
282282
283283
[Read more about how streaming HTML works.](https://github.com/reactwg/react-18/discussions/37)
284284
285-
<Note>
286-
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.
298-
299-
</Note>
300-
301285
---
302286
303287
### Specifying what goes into the shell {/*specifying-what-goes-into-the-shell*/}

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -281,22 +281,6 @@ Streaming does not need to wait for React itself to load in the browser, or for
281281
282282
[Read more about how streaming HTML works.](https://github.com/reactwg/react-18/discussions/37)
283283
284-
<Note>
285-
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.
297-
298-
</Note>
299-
300284
---
301285
302286
### Specifying what goes into the shell {/*specifying-what-goes-into-the-shell*/}

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -271,22 +271,6 @@ function ProfilePage() {
271271
272272
Imagine that `<Posts />` needs to load some data, which takes some time. Ideally, you'd want wait for the posts to finish so it's included in the HTML. To do this, you can use Suspense to suspend on the data, and `prerender` will wait for the suspended content to finish before resolving to the static HTML.
273273
274-
<Note>
275-
276-
**Only Suspense-enabled data sources will activate the Suspense component.** They include:
277-
278-
- 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)
279-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
280-
- Reading the value of a Promise with [`use`](/reference/react/use)
281-
282-
Suspense **does not** detect when data is fetched inside an Effect or event handler.
283-
284-
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.
285-
286-
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-
288-
</Note>
289-
290274
---
291275
292276
### Aborting prerendering {/*aborting-prerendering*/}

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -271,22 +271,6 @@ function ProfilePage() {
271271
272272
Imagine that `<Posts />` needs to load some data, which takes some time. Ideally, you'd want wait for the posts to finish so it's included in the HTML. To do this, you can use Suspense to suspend on the data, and `prerenderToNodeStream` will wait for the suspended content to finish before resolving to the static HTML.
273273
274-
<Note>
275-
276-
**Only Suspense-enabled data sources will activate the Suspense component.** They include:
277-
278-
- 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)
279-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
280-
- Reading the value of a Promise with [`use`](/reference/react/use)
281-
282-
Suspense **does not** detect when data is fetched inside an Effect or event handler.
283-
284-
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.
285-
286-
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-
288-
</Note>
289-
290274
---
291275
292276
### Aborting prerendering {/*aborting-prerendering*/}

src/content/reference/react/Activity.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -870,17 +870,9 @@ Pre-rendering components with hidden Activity boundaries is a powerful way to re
870870

871871
<Note>
872872

873-
**Only Suspense-enabled data sources will be fetched during pre-rendering.** They include:
873+
**Activity does not fetch data inside an Effect during pre-render.**
874874

875-
- 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)
876-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
877-
- Reading the value of a cached Promise with [`use`](/reference/react/use)
878-
879-
Activity **does not** detect data that is fetched inside an Effect.
880-
881-
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.
882-
883-
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.
875+
Since Effects are not mounted, only data fetched in render using Suspense will be pre-rendered.
884876

885877
</Note>
886878

src/content/reference/react/Suspense.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,14 @@ async function getAlbums() {
205205

206206
<Note>
207207

208-
**Only Suspense-enabled data sources will activate the Suspense component.** They include:
208+
**The Suspense component is activated by suspending.** This includes:
209209

210-
- 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)
211-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
212-
- Reading the value of a cached Promise with [`use`](/reference/react/use)
210+
- Reading the value of a Promise with [`use`](/reference/react/use).
211+
- Lazy-loading component code with [`lazy`](/reference/react/lazy).
212+
- Data-fetching libraries that suspend, like [TanStack Query](https://tanstack.com/query/latest/docs/framework/react/guides/suspense) and [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/).
213+
- Frameworks that support [Server Components](/reference/rsc/server-components), like [React Router v7](/learn/start-a-new-react-project#react-router-v7) and [Next.js App Router](/learn/start-a-new-react-project#nextjs-app-router).
213214

214-
Suspense **does not** detect when data is fetched inside an Effect or event handler.
215-
216-
The exact way you would load data in the `Albums` component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
217-
218-
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.
215+
Suspense **does not** activate when data is fetched inside an Effect or event handler.
219216

220217
</Note>
221218

@@ -1681,7 +1678,9 @@ A Transition doesn't wait for *all* content to load. It only waits long enough t
16811678
16821679
<Note>
16831680
1684-
Suspense-enabled routers are expected to wrap the navigation updates into Transitions by default.
1681+
To support [Suspense](/reference/react/Suspense), Routers are expected to wrap the navigation updates into Transitions by default.
1682+
1683+
See [Building a Suspense-enabled router](/reference/react/useTransition#building-a-suspense-enabled-router) for more info.
16851684
16861685
</Note>
16871686

src/content/reference/react/useDeferredValue.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,6 @@ During updates, the <CodeStep step={2}>deferred value</CodeStep> will "lag behin
8484

8585
**Let's walk through an example to see when this is useful.**
8686

87-
<Note>
88-
89-
This example assumes you use a Suspense-enabled data source:
90-
91-
- 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/getting-started/fetching-data#with-suspense)
92-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
93-
- Reading the value of a Promise with [`use`](/reference/react/use)
94-
95-
[Learn more about Suspense and its limitations.](/reference/react/Suspense)
96-
97-
</Note>
98-
99-
10087
In this example, the `SearchResults` component [suspends](/reference/react/Suspense#displaying-a-fallback-while-content-is-loading) while fetching the search results. Try typing `"a"`, waiting for the results, and then editing it to `"ab"`. The results for `"a"` get replaced by the loading fallback.
10188

10289
<Sandpack>

src/content/reference/react/useTransition.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,11 @@ main {
15511551
15521552
<Note>
15531553
1554-
[Suspense-enabled](/reference/react/Suspense) routers are expected to wrap the navigation updates into Transitions by default.
1554+
To support [Suspense](/reference/react/Suspense), Routers are expected to wrap the navigation updates into Transitions by default.
1555+
1556+
This allows Routers to automatically support [displaying a fallback while content is loading](/reference/react/Suspense#displaying-a-fallback-while-content-is-loading) when navigating to new routes, and [preventing already revealed content from hiding](/reference/react/Suspense#preventing-already-revealed-content-from-hiding) when refreshing the current route.
1557+
1558+
Popular routers like [TanStack Router](https://tanstack.com/router/latest) and [React Router](https://reactrouter.com/) already support transitions by default.
15551559
15561560
</Note>
15571561

0 commit comments

Comments
 (0)