Skip to content

Commit 3d6a225

Browse files
committed
typing fix
1 parent b763a64 commit 3d6a225

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/useInfiniteScroll.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useEffect } from 'react';
22
import {
33
useTrackVisibility,
4+
IntersectionObserverHookArgs,
45
IntersectionObserverHookRefCallback,
56
IntersectionObserverHookRootRefCallback,
67
} from 'react-intersection-observer-hook';
@@ -12,21 +13,23 @@ export type UseInfiniteScrollHookResult = [
1213
{ rootRef: IntersectionObserverHookRootRefCallback },
1314
];
1415

15-
export interface UseInfiniteScrollHookArgs {
16+
export type UseInfiniteScrollHookArgs = Pick<
17+
IntersectionObserverHookArgs,
18+
// We pass this to 'IntersectionObserver'. We can use it to configure when to trigger 'onLoadMore'.
19+
'rootMargin'
20+
> & {
1621
// Some sort of "is fetching" info of the request.
1722
loading: boolean;
1823
// If the list has more items to load.
1924
hasNextPage: boolean;
2025
// The callback function to execute when the 'onLoadMore' is triggered.
2126
// eslint-disable-next-line no-undef
2227
onLoadMore: VoidFunction;
23-
// We pass this to 'IntersectionObserver'. We can use it to configure when to trigger 'onLoadMore'.
24-
rootMargin?: string;
2528
// Flag to stop infinite scrolling. Can be used in case of an error etc too.
2629
disabled?: boolean;
2730
// How long it should wait before triggering 'onLoadMore'.
2831
delayInMs?: number;
29-
}
32+
};
3033

3134
function useInfiniteScroll({
3235
loading,

0 commit comments

Comments
 (0)