Skip to content

Commit 7d6e6ec

Browse files
authored
docs: change Hydrate->HydrationBoundary (#5455)
* updated docs on SSR Hydrate -> HydrationBoundary * docs(ssr): change Hydrate->HydrationBoundary change Hydrate->HydrationBoundary to remove deprecated component * docs(ssr): rename all Hydrate->HydrationBoundary rename all Hydrate instances ->HydrationBoundary for consistency
1 parent 35d2663 commit 7d6e6ec

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

docs/react/guides/ssr.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -302,19 +302,19 @@ ReactDOM.hydrate(
302302

303303
## Using the `app` Directory in Next.js 13
304304

305-
Both prefetching approaches, using `initialData` or `<Hydrate>`, are available within the `app` directory.
305+
Both prefetching approaches, using `initialData` or `<HydrationBoundary>`, are available within the `app` directory.
306306

307307
- Prefetch the data in a Server Component and prop drill `initialData` to Client Components
308308
- Quick to set up for simple cases
309309
- May need to prop drill through multiple layers of Client Components
310310
- May need to prop drill to multiple Client Components using the same query
311311
- Query refetching is based on when the page loads instead of when the data was prefetched on the server
312-
- Prefetch the query on the server, dehydrate the cache and rehydrate it on the client with `<Hydrate>`
312+
- Prefetch the query on the server, dehydrate the cache and rehydrate it on the client with `<HydrationBoundary>`
313313
- Requires slightly more setup up front
314314
- No need to prop drill
315315
- Query refetching is based on when the query was prefetched on the server
316316

317-
### `<QueryClientProvider>` is required by both the `initialData` and `<Hydrate>` prefetching approaches
317+
### `<QueryClientProvider>` is required by both the `initialData` and `<HydrationBoundary>` prefetching approaches
318318

319319
The hooks provided by the `react-query` package need to retrieve a `QueryClient` from their context. Wrap your component tree with `<QueryClientProvider>` and pass it an instance of `QueryClient`.
320320

@@ -379,7 +379,7 @@ export function Posts(props) {
379379
}
380380
```
381381

382-
### Using `<Hydrate>`
382+
### Using `<HydrationBoundary>`
383383

384384
Create a request-scoped singleton instance of `QueryClient`. **This ensures that data is not shared between different users and requests, while still only creating the QueryClient once per request.**
385385

@@ -397,30 +397,33 @@ Fetch your data in a Server Component higher up in the component tree than the C
397397
- Retrieve the `QueryClient` singleton instance
398398
- Prefetch the data using the client's prefetchQuery method and wait for it to complete
399399
- Use `dehydrate` to obtain the dehydrated state of the prefetched queries from the query cache
400-
- Wrap the component tree that needs the prefetched queries inside `<Hydrate>`, and provide it with the dehydrated state
401-
- You can fetch inside multiple Server Components and use `<Hydrate>` in multiple places
400+
- Wrap the component tree that needs the prefetched queries inside `<HydrationBoundary>`, and provide it with the dehydrated state
401+
- You can fetch inside multiple Server Components and use `<HydrationBoundary>` in multiple places
402402

403403
> NOTE: TypeScript currently complains of a type error when using async Server Components. As a temporary workaround, use `{/* @ts-expect-error Server Component */}` when calling this component inside another. For more information, see [End-to-End Type Safety](https://beta.nextjs.org/docs/configuring/typescript#end-to-end-type-safety) in the Next.js 13 beta docs.
404404
405405
```tsx
406406
// app/hydratedPosts.jsx
407-
import { dehydrate, Hydrate } from '@tanstack/react-query'
407+
import { dehydrate, HydrationBoundary } from '@tanstack/react-query'
408408
import getQueryClient from './getQueryClient'
409409

410410
export default async function HydratedPosts() {
411411
const queryClient = getQueryClient()
412-
await queryClient.prefetchQuery(['posts'], getPosts)
412+
413+
await queryClient.prefetchQuery({querykey:['posts'], queryFn:getPosts})
414+
// for infinite queries with useInfiniteQuery use
415+
// await queryClient.prefetchInfiniteQuery({queryKey:['posts'], queryFn:getPosts,...})
413416
const dehydratedState = dehydrate(queryClient)
414417

415418
return (
416-
<Hydrate state={dehydratedState}>
419+
<HydrationBoundary state={dehydratedState}>
417420
<Posts />
418-
</Hydrate>
421+
</HydrationBoundary>
419422
)
420423
}
421424
```
422425

423-
During server rendering, calls to `useQuery` nested within the `<Hydrate>` Client Component will have access to prefetched data provided in the state property.
426+
During server rendering, calls to `useQuery` nested within the `<HydrationBoundary>` Client Component will have access to prefetched data provided in the state property.
424427

425428
```tsx
426429
// app/posts.jsx

docs/svelte/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Svelte Query offers useful functions and components that will make managing serv
6464
- `useIsMutating`
6565
- `useHydrate`
6666
- `<QueryClientProvider>`
67-
- `<Hydrate>`
67+
- `<HydrationBoundary>`
6868

6969
## Important Differences between Svelte Query & React Query
7070

0 commit comments

Comments
 (0)