1 | import { useRef } from 'react' |
||
2 | import { useIntersectionObserver } from 'shared/hooks/useIntersectionObserver' |
||
3 | |||
4 | interface IProps { |
||
5 | onIntersect: () => void |
||
6 | enabled: boolean |
||
7 | } |
||
8 | |||
9 | const InfiniteScrollTrigger = ({ onIntersect, enabled }: IProps) => { |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
10 | const loadMore = useRef<HTMLDivElement | null>(null) |
||
11 | |||
12 | useIntersectionObserver({ |
||
13 | target: loadMore, |
||
14 | onIntersect, |
||
15 | enabled, |
||
16 | rootMargin: '2000px', |
||
17 | }) |
||
18 | |||
19 | return ( |
||
20 | <div |
||
0 ignored issues
–
show
|
|||
21 | ref={loadMore} |
||
0 ignored issues
–
show
|
|||
22 | style={{ background: 'transparent', padding: '20px' }} |
||
0 ignored issues
–
show
|
|||
23 | /> |
||
24 | ) |
||
25 | } |
||
26 | |||
27 | export { InfiniteScrollTrigger } |
||
28 |