fix: search

This commit is contained in:
ner committed 2024-11-03 19:22:19 +02:00
1 parent 995342f18a
commit 99255f4f13
7 files changed
+27 -13

No files matched your search

+14 -2
View File
@@ -2,14 +2,26 @@ import { useMemo } from 'react';
import { QueryKey, useInfiniteQuery, useSuspenseInfiniteQuery } from '@tanstack/react-query';
interface Props {
enabled?: boolean;
queryKey: QueryKey;
queryFn: ({ pageParam }: { pageParam: string }) => Promise<Pagination<Show>>;
initialPageParam?: string;
getNextPageParam?: () => string | undefined;
mode?: 'suspense' | 'default';
}
const useInfiniteList = ({ queryKey, queryFn, initialPageParam, getNextPageParam }: Props) => {
const { data, hasNextPage, fetchNextPage, isFetched, isLoading } = useSuspenseInfiniteQuery({
const useInfiniteList = ({
queryKey,
queryFn,
initialPageParam,
getNextPageParam,
mode = 'suspense',
enabled
}: Props) => {
const { data, hasNextPage, fetchNextPage, isFetched, isLoading } = (
mode === 'suspense' ? useSuspenseInfiniteQuery : useInfiniteQuery
)({
enabled: mode === 'default' ? enabled : undefined,
queryKey,
queryFn: ({ pageParam }) => queryFn({ pageParam }),
getNextPageParam: