fix: search
This commit is contained in:
1 parent
995342f18a
commit
99255f4f13
7 files changed
+27
-13
No files matched your search
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user