Skip to content

Commit

Permalink
Use variable instead of useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Oct 25, 2024
1 parent b92456a commit 026e88a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions components/wallet-logger.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 026e88a

Please sign in to comment.