fix: back to prefetch

This commit is contained in:
ner committed 2024-10-29 18:25:52 +02:00
1 parent a268f7c38d
commit c9ca262da8
14 files changed
+180 -27

No files matched your search

+9 -4
View File
@@ -7,18 +7,23 @@ const TOTAL_PAGES = 400;
export const generatePage = createUniqueRandomGenerator(TOTAL_PAGES);
const randomQuery = () => ({
export type RandomQueryProps = {
page: number;
};
const randomQuery = ({ page }: RandomQueryProps) => ({
suspense: true,
queryKey: ['random-movie'],
initialPageParam: '1',
queryFn: () =>
initialPageParam: page.toString(),
getNextPageParam: () => generatePage().toString(),
queryFn: ({ pageParam }: { pageParam: string }) =>
movieAdvisor
.get<TMDBPagination<Movie>>('/discover/movie', {
params: {
'vote_count.gte': 300,
sort_by: 'popularity.desc',
with_origin_country: 'UA|GB|JP|AU|US|IT|DE|FR',
page: generatePage()
page: pageParam
}
})
.then(mapMoviesSeriesResponseToShows)