Skip to content

Commit

Permalink
Initialise nextFocusRevalidatedAt on mount
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoodfellow committed Mar 7, 2024
1 parent b103154 commit 3ba72d8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/use-swr.ts
Expand Up @@ -581,9 +581,15 @@ export const useSWRHandler = <Data = any, Error = any>(

const softRevalidate = revalidate.bind(UNDEFINED, WITH_DEDUPE)

let nextFocusRevalidatedAt = 0

if (getConfig().revalidateOnFocus) {
const initNow = Date.now()
nextFocusRevalidatedAt = initNow + getConfig().focusThrottleInterval
}

// Expose revalidators to global event listeners. So we can trigger
// revalidation from the outside.
let nextFocusRevalidatedAt = 0
const onRevalidate = (
type: RevalidateEvent,
opts: {
Expand Down

0 comments on commit 3ba72d8

Please sign in to comment.