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

Function shouldFetchOnMount

packages/query-core/src/queryObserver.ts:902–911  ·  view source on GitHub ↗

* Checks whether a query should fetch when an observer mounts: either for its initial load, or * because it has data and `refetchOnMount` asks for a refetch. * @param query - The query to check. * @param options - The observer options. * @returns `true` if the query should fetch on mount.

(
  query: Query<any, any, any, any>,
  options: QueryObserverOptions<any, any, any, any, any>,
)

Source from the content-addressed store, hash-verified

900 * @returns `true` if the query should fetch on mount.
901 */
902function shouldFetchOnMount(
903 query: Query<any, any, any, any>,
904 options: QueryObserverOptions<any, any, any, any, any>,
905): boolean {
906 return (
907 shouldLoadOnMount(query, options) ||
908 (query.state.data !== undefined &&
909 shouldFetchOn(query, options, options.refetchOnMount))
910 )
911}
912
913/**
914 * Checks whether a query should fetch for a `refetchOnMount`, `refetchOnWindowFocus`, or

Callers 2

onSubscribeMethod · 0.85
createResultMethod · 0.85

Calls 2

shouldLoadOnMountFunction · 0.85
shouldFetchOnFunction · 0.85

Tested by

no test coverage detected