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

Function shouldFetchOnMount

packages/query-core/src/queryObserver.ts:898–907  ·  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

896 * @returns `true` if the query should fetch on mount.
897 */
898function shouldFetchOnMount(
899 query: Query<any, any, any, any>,
900 options: QueryObserverOptions<any, any, any, any, any>,
901): boolean {
902 return (
903 shouldLoadOnMount(query, options) ||
904 (query.state.data !== undefined &&
905 shouldFetchOn(query, options, options.refetchOnMount))
906 )
907}
908
909/**
910 * 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