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

Method isStatic

packages/query-core/src/query.ts:508–521  ·  view source on GitHub ↗

* Returns `true` if the query has data and at least one observer configured with * `staleTime: 'static'`, meaning it is treated as never stale. * @returns `true` if the query is static.

()

Source from the content-addressed store, hash-verified

506 * @returns `true` if the query is static.
507 */
508 isStatic(): boolean {
509 if (this.state.data === undefined) {
510 return false
511 }
512
513 if (this.getObserversCount() > 0) {
514 return this.observers.some(
515 (observer) =>
516 resolveQueryValue(observer.options.staleTime, this) === 'static',
517 )
518 }
519
520 return false
521 }
522
523 /**
524 * Returns `true` if the query is stale.

Callers 2

QueryRowFunction · 0.80
refetchQueriesMethod · 0.80

Calls 2

getObserversCountMethod · 0.95
resolveQueryValueFunction · 0.90

Tested by

no test coverage detected