From b90f84ee110b89f8f54ca2511eee746e6c0fc642 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Fri, 26 Apr 2024 22:14:29 +0200 Subject: [PATCH] Prevent triggering load more requests while loading --- src/components/MangaGrid.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/MangaGrid.tsx b/src/components/MangaGrid.tsx index cce67042..d06da71b 100644 --- a/src/components/MangaGrid.tsx +++ b/src/components/MangaGrid.tsx @@ -291,6 +291,10 @@ export const MangaGrid: React.FC = (props) => { const gridHeight = entries[0].target.clientHeight; const isScrollbarVisible = gridHeight > document.documentElement.clientHeight; + if (isLoading) { + return; + } + if (!gridHeight) { return; } @@ -306,7 +310,7 @@ export const MangaGrid: React.FC = (props) => { resizeObserver.observe(gridRef.current); return () => resizeObserver.disconnect(); - }, [loadMore]); + }, [loadMore, isLoading]); const hasNoItems = !isLoading && mangas.length === 0; if (hasNoItems) {