feat: ReactQueryStreamedHydration
This commit is contained in:
1 parent
0e146b0c53
commit
e9c0f3bef3
12 files changed
+71
-52
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental';
|
||||
import { Metadata } from 'next';
|
||||
|
||||
import UsersList from '@/components/UsersLists';
|
||||
@@ -20,13 +20,13 @@ const Favorites = async () => {
|
||||
const showType = 'movie';
|
||||
|
||||
if (session) {
|
||||
await queryClient.prefetchInfiniteQuery(usersShowsQuery({ showType, list, session }));
|
||||
queryClient.prefetchInfiniteQuery(usersShowsQuery({ showType, list, session }));
|
||||
}
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<ReactQueryStreamedHydration>
|
||||
<UsersList session={session} list={list} label='favorites' />
|
||||
</HydrationBoundary>
|
||||
</ReactQueryStreamedHydration>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
+5
-5
@@ -1,19 +1,19 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental';
|
||||
|
||||
import randomQuery from '@/data/queries/random';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
|
||||
const Random = async () => {
|
||||
const Random = () => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
await queryClient.prefetchInfiniteQuery(randomQuery());
|
||||
queryClient.prefetchInfiniteQuery(randomQuery());
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<ReactQueryStreamedHydration>
|
||||
<Container />
|
||||
</HydrationBoundary>
|
||||
</ReactQueryStreamedHydration>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental';
|
||||
import { Metadata } from 'next';
|
||||
|
||||
import popularQuery from '@/data/queries/popular';
|
||||
@@ -12,15 +12,15 @@ export const metadata: Metadata = {
|
||||
description: `Check out the most popular movies right now on ${TITLE}. See what’s trending and don’t miss out on the latest hits.`
|
||||
};
|
||||
|
||||
const Popular = async () => {
|
||||
const Popular = () => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
await queryClient.prefetchInfiniteQuery(popularQuery());
|
||||
queryClient.prefetchInfiniteQuery(popularQuery());
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<ReactQueryStreamedHydration>
|
||||
<Container />
|
||||
</HydrationBoundary>
|
||||
</ReactQueryStreamedHydration>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental';
|
||||
|
||||
import similarQuery from '@/data/queries/similar';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
|
||||
const Similar = async ({ searchParams }: { searchParams: Record<string, string> }) => {
|
||||
const Similar = ({ searchParams }: { searchParams: Record<string, string> }) => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
const { id, type } = searchParams || {};
|
||||
|
||||
await queryClient.prefetchInfiniteQuery(similarQuery({ showId: id, showType: type as Show['type'] }));
|
||||
queryClient.prefetchInfiniteQuery(similarQuery({ showId: id, showType: type as Show['type'] }));
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<ReactQueryStreamedHydration>
|
||||
<Container />
|
||||
</HydrationBoundary>
|
||||
</ReactQueryStreamedHydration>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental';
|
||||
|
||||
import popularQuery from '@/data/queries/popular';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
|
||||
const Starring = async ({ searchParams }: { searchParams: Record<string, string> }) => {
|
||||
const Starring = ({ searchParams }: { searchParams: Record<string, string> }) => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
const { actorId } = searchParams || {};
|
||||
|
||||
await queryClient.prefetchInfiniteQuery(popularQuery({ sortBy: 'vote_average.desc', starring: actorId }));
|
||||
queryClient.prefetchInfiniteQuery(popularQuery({ sortBy: 'vote_average.desc', starring: actorId }));
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<ReactQueryStreamedHydration>
|
||||
<Container />
|
||||
</HydrationBoundary>
|
||||
</ReactQueryStreamedHydration>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental';
|
||||
import { Metadata } from 'next';
|
||||
|
||||
import popularQuery from '@/data/queries/popular';
|
||||
@@ -12,15 +12,15 @@ export const metadata: Metadata = {
|
||||
description: `Discover the top-rated movies on ${TITLE}. Find the highest-rated films and make informed viewing choices.`
|
||||
};
|
||||
|
||||
const Top = async () => {
|
||||
const Top = () => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
await queryClient.prefetchInfiniteQuery(popularQuery({ sortBy: 'vote_average.desc' }));
|
||||
queryClient.prefetchInfiniteQuery(popularQuery({ sortBy: 'vote_average.desc' }));
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<ReactQueryStreamedHydration>
|
||||
<Container />
|
||||
</HydrationBoundary>
|
||||
</ReactQueryStreamedHydration>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental';
|
||||
import { Metadata } from 'next';
|
||||
|
||||
import UsersList from '@/components/UsersLists';
|
||||
@@ -20,13 +21,13 @@ const WatchList = async () => {
|
||||
const showType = 'movie';
|
||||
|
||||
if (session) {
|
||||
await queryClient.prefetchInfiniteQuery(usersShowsQuery({ showType, list, session }));
|
||||
queryClient.prefetchInfiniteQuery(usersShowsQuery({ showType, list, session }));
|
||||
}
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<ReactQueryStreamedHydration>
|
||||
<UsersList session={session} list={list} label='watch' />
|
||||
</HydrationBoundary>
|
||||
</ReactQueryStreamedHydration>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user