MCPcopy Create free account
hub / github.com/TanStack/query / isStaleByTime

Method isStaleByTime

packages/query-core/src/query.ts:314–329  ·  view source on GitHub ↗
(staleTime: StaleTime = 0)

Source from the content-addressed store, hash-verified

312 }
313
314 isStaleByTime(staleTime: StaleTime = 0): boolean {
315 // no data is always stale
316 if (this.state.data === undefined) {
317 return true
318 }
319 // static is never stale
320 if (staleTime === 'static') {
321 return false
322 }
323 // if the query is invalidated, it is stale
324 if (this.state.isInvalidated) {
325 return true
326 }
327
328 return !timeUntilStale(this.state.dataUpdatedAt, staleTime)
329 }
330
331 onFocus(): void {
332 const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus())

Callers 4

ensureQueryDataMethod · 0.80
queryMethod · 0.80
fetchQueryMethod · 0.80
isStaleFunction · 0.80

Calls 1

timeUntilStaleFunction · 0.90

Tested by

no test coverage detected