upd: scroll

This commit is contained in:
amel
2024-09-19 16:07:45 +08:00
parent 0459bb3656
commit da3f604855
3 changed files with 12 additions and 14 deletions

View File

@@ -31,13 +31,11 @@ export default function ListAnnouncement() {
setLoading(true)
const response = await funGetAllAnnouncement('?search=' + searchQuery + '&page=' + isPage)
if (response.success) {
// if (response.data.length > 0) {
if (isPage == 1) {
setIsData(response?.data)
} else {
setIsData([...isData, ...response?.data])
}
// }
} else {
toast.error(response.message);
}
@@ -79,7 +77,6 @@ export default function ListAnnouncement() {
const scrollTop = containerRef.current.scrollTop;
const containerHeight = containerRef.current.clientHeight;
const scrollHeight = containerRef.current.scrollHeight;
if (scrollTop + containerHeight >= scrollHeight) {
setPage(isPage + 1)
}