Skip to content

Commit d250073

Browse files
committed
feat(useQuery): make refetchInterval accept a function
always pass nextInterval to updateRefetchInterval
1 parent 006f88d commit d250073

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/core/queryObserver.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,13 @@ export class QueryObserver<
371371
private computeRefetchInterval() {
372372
return typeof this.options.refetchInterval === 'function'
373373
? this.options.refetchInterval(this.currentResult.data, this.currentQuery)
374-
: this.options.refetchInterval
374+
: this.options.refetchInterval ?? 0
375375
}
376376

377-
private updateRefetchInterval(nextInterval?: number | false): void {
377+
private updateRefetchInterval(nextInterval: number | false): void {
378378
this.clearRefetchInterval()
379379

380-
this.currentRefetchInterval = nextInterval ?? this.computeRefetchInterval()
380+
this.currentRefetchInterval = nextInterval
381381

382382
if (
383383
isServer ||
@@ -400,7 +400,7 @@ export class QueryObserver<
400400

401401
private updateTimers(): void {
402402
this.updateStaleTimeout()
403-
this.updateRefetchInterval()
403+
this.updateRefetchInterval(this.computeRefetchInterval())
404404
}
405405

406406
private clearTimers(): void {

0 commit comments

Comments
 (0)