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 Dec 12, 2023
1 parent 1d81109 commit afcf286
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/src/use-swr.ts
Expand Up @@ -574,9 +574,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 afcf286

Please sign in to comment.