@@ -78,21 +78,24 @@ const InfiniteScroll = ({
7878 el . scrollHeight - parentElement . scrollTop - parentElement . clientHeight ;
7979 reverseOffset = parentElement . scrollTop ;
8080 }
81- if ( listenToScroll ) listenToScroll ( offset , reverseOffset ) ;
81+ if ( listenToScroll ) {
82+ listenToScroll ( offset , reverseOffset , threshold ) ;
83+ }
8284
8385 // Here we make sure the element is visible as well as checking the offset
8486 if (
8587 ( isReverse ? reverseOffset : offset ) < Number ( threshold ) &&
8688 el . offsetParent !== null &&
87- typeof loadMore === 'function'
89+ typeof loadMore === 'function' &&
90+ hasMore
8891 ) {
8992 loadMore ( ) ;
9093 }
91- } , [ useWindow , isReverse , threshold , listenToScroll , loadMore ] ) ;
94+ } , [ hasMore , useWindow , isReverse , threshold , listenToScroll , loadMore ] ) ;
9295
9396 useEffect ( ( ) => {
9497 const scrollEl = useWindow ? window : scrollComponent . current ?. parentNode ;
95- if ( ! hasMore || isLoading || ! scrollEl ) {
98+ if ( isLoading || ! scrollEl ) {
9699 return ( ) => { } ;
97100 }
98101
@@ -107,7 +110,7 @@ const InfiniteScroll = ({
107110 scrollEl . removeEventListener ( 'scroll' , scrollListener , useCapture ) ;
108111 scrollEl . removeEventListener ( 'resize' , scrollListener , useCapture ) ;
109112 } ;
110- } , [ hasMore , initialLoad , isLoading , scrollListener , useCapture , useWindow ] ) ;
113+ } , [ initialLoad , isLoading , scrollListener , useCapture , useWindow ] ) ;
111114
112115 useEffect ( ( ) => {
113116 const scrollEl = useWindow ? window : scrollComponent . current ?. parentNode ;
0 commit comments