Skip to content

Commit 3c10762

Browse files
committed
fix: implemented client side infinite scroll
1 parent 9f88d4a commit 3c10762

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/apps/talent-search/src/routes/search-results-page/SearchResultsPage.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,27 @@ const SearchResultsPage: FC = () => {
3131
const paginatedMatches = matches.slice(0, currentPage * itemsPerPage)
3232

3333
useEffect(() => {
34-
const handleScroll = () => {
35-
const scrollY = window.scrollY
36-
const visibleHeight = window.innerHeight
37-
const fullHeight = document.body.scrollHeight
38-
39-
if (scrollY + visibleHeight >= fullHeight - 100) {
34+
const handleScroll: () => void = () => {
35+
const scrollY = window.scrollY
36+
const visibleHeight = window.innerHeight
37+
const fullHeight = document.body.scrollHeight
38+
39+
if (scrollY + visibleHeight >= fullHeight - 100) {
4040
// Scroll near bottom
41-
setCurrentPage(prev => {
42-
const maxPages = Math.ceil(matches.length / itemsPerPage)
43-
return prev < maxPages ? prev + 1 : prev
44-
})
45-
}
41+
setCurrentPage(prev => {
42+
const maxPages = Math.ceil(matches.length / itemsPerPage)
43+
return prev < maxPages ? prev + 1 : prev
44+
})
45+
}
4646
}
47-
47+
4848
window.addEventListener('scroll', handleScroll)
4949
return () => window.removeEventListener('scroll', handleScroll)
50-
}, [matches])
50+
}, [matches])
5151

52-
useEffect(() => {
52+
useEffect(() => {
5353
setCurrentPage(1)
54-
}, [skills, matches])
54+
}, [skills, matches])
5555

5656
const toggleSkillsModal = useCallback(() => setShowSkillsModal(s => !s), [])
5757

0 commit comments

Comments
 (0)