From 08def8a372184abe1c9cd54b83565d90fa8c5a6b Mon Sep 17 00:00:00 2001 From: Amit Ghosh <29959138+maverickamit@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:15:45 +0530 Subject: [PATCH] Auto load lending desks when less than 3 lending desks are available to be displayed on QuickLoan --- dapp-v1/src/pages/borrower/QuickLoan.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dapp-v1/src/pages/borrower/QuickLoan.tsx b/dapp-v1/src/pages/borrower/QuickLoan.tsx index 443c01e..27ac5d3 100644 --- a/dapp-v1/src/pages/borrower/QuickLoan.tsx +++ b/dapp-v1/src/pages/borrower/QuickLoan.tsx @@ -128,6 +128,16 @@ const renderLendingDesks = ({ } }, [items, loading, error]); + // This useEffect hook automatically loads more lending desks when: + // 1. The current number of lending desks is less than 3 + // 2. There are more lending desks available to load + // 3. No loading operation is currently in progress + useEffect(() => { + if (flatResult.length < 3 && hasNextPage && !loading) { + loadMore(); + } + }, [flatResult, hasNextPage, loading]); + return (
{flatResult.length > 0 ? (