Remove fetchPreviousPage from fetchMore

This commit is contained in:
Jackson Harper
2024-08-19 16:21:34 +08:00
parent 529a81dd8a
commit ca1dba7bd6
2 changed files with 4 additions and 11 deletions

View File

@ -59,7 +59,7 @@ export function HighlightsContainer(): JSX.Element {
setSize(size + 1)
}, [isLoading, hasMore, setSize, size])
// useFetchMore(handleFetchMore)
useFetchMore(handleFetchMore)
const highlights = useMemo(() => {
if (!data) {

View File

@ -1,10 +1,6 @@
import { useEffect, useRef, useState } from 'react'
export const useFetchMore = (
fetchNextPage: () => void,
// fetchPreviousPage: () => void,
delay = 500
): void => {
export const useFetchMore = (fetchNextPage: () => void, delay = 500): void => {
const [first, setFirst] = useState(true)
const [lastScrollTop, setLastScrollTop] = useState(0)
const throttleTimeout = useRef<NodeJS.Timeout | undefined>(undefined)
@ -21,10 +17,7 @@ export const useFetchMore = (
scrollTop + clientHeight >= scrollHeight - scrollHeight / 3
) {
fetchNextPage()
} /* else if (direction == 'up' && scrollTop < 300) {
console.log('calling fetchPrevious: ', scrollTop)
fetchPreviousPage()
} */
}
throttleTimeout.current = undefined
}
@ -45,5 +38,5 @@ export const useFetchMore = (
return () => {
window.removeEventListener('scroll', handleScroll)
}
}, [fetchNextPage, /* fetchPreviousPage, */ delay, first, setFirst])
}, [fetchNextPage, delay, first, setFirst])
}