Skip to content

Commit c350f22

Browse files
author
qiaoyuwen
committed
feat: useInfinitePagination options
1 parent a766a08 commit c350f22

File tree

1 file changed

+3
-0
lines changed
  • packages/react-hooks/src/pagination

1 file changed

+3
-0
lines changed

packages/react-hooks/src/pagination/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import { useMemo } from 'react';
2+
import type { SWRInfiniteConfiguration } from 'swr';
23
import { useSWRInfinite } from 'swr';
34

45
export function useInfinitePagination<T, P = Record<string, any>>(
56
key: string,
67
fetcher: (current: number, pageSize: number, params?: P) => Promise<T[]>,
78
pageSize: number,
89
params?: P,
10+
options?: SWRInfiniteConfiguration,
911
) {
1012
const { data, error, mutate, size, setSize, isValidating } = useSWRInfinite<T[], P>(
1113
(current) => [key, current + 1, pageSize, params],
1214
(_, current, _pageSize, _params) => fetcher(current, _pageSize, _params),
15+
options,
1316
);
1417

1518
const returnObj = useMemo(() => {

0 commit comments

Comments
 (0)