From 026e88aa089420b8e5f21c231f7b58b0d06e729a Mon Sep 17 00:00:00 2001 From: ekzyis Date: Fri, 25 Oct 2024 20:06:39 +0200 Subject: [PATCH] Use variable instead of useEffect --- components/wallet-logger.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/components/wallet-logger.js b/components/wallet-logger.js index f7d3ea922..406c0dd8b 100644 --- a/components/wallet-logger.js +++ b/components/wallet-logger.js @@ -1,5 +1,5 @@ import LogMessage from './log-message' -import { useCallback, useEffect, useMemo, useState } from 'react' +import { useCallback, useMemo, useState } from 'react' import styles from '@/styles/log.module.css' import { Button } from 'react-bootstrap' import { useToast } from './toast' @@ -273,16 +273,13 @@ export function useWalletLogs (wallet, initialPage = 1, logsPerPage = 10) { } }, [logs, loadLogsPage, wallet]) - useEffect(() => { - // make sure 'more' button is removed if logs are deleted - if (logs.length === 0) setHasMore(false) - }, [logs?.length]) - useInterval(() => { loadNew().catch(console.error) }, 1_000, [loadNew]) - return { logs, hasMore, loadMore, setLogs, loading } + // make sure 'more' button is removed if logs are deleted + const nextHasMore = logs?.length !== 0 && hasMore + return { logs, hasMore: nextHasMore, loadMore, setLogs, loading } } function uniqueSort (logs) {