File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
examples/load-more-infinite-scroll Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,13 @@ export default function useIntersectionObserver({
6
6
onIntersect,
7
7
threshold = 1.0 ,
8
8
rootMargin = '0px' ,
9
+ enabled = true ,
9
10
} ) {
10
11
React . useEffect ( ( ) => {
12
+ if ( ! enabled ) {
13
+ return
14
+ }
15
+
11
16
const observer = new IntersectionObserver (
12
17
entries =>
13
18
entries . forEach ( entry => entry . isIntersecting && onIntersect ( ) ) ,
@@ -29,5 +34,5 @@ export default function useIntersectionObserver({
29
34
return ( ) => {
30
35
observer . unobserve ( el )
31
36
}
32
- } , [ target . current ] )
37
+ } , [ target . current , enabled ] )
33
38
}
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ export default () => {
34
34
useIntersectionObserver ( {
35
35
target : loadMoreButtonRef ,
36
36
onIntersect : fetchMore ,
37
+ enabled : canFetchMore ,
37
38
} )
38
39
39
40
return (
You can’t perform that action at this time.
0 commit comments