What this thread does
Do first: make enabled false until every required filter is valid, and drive the initial spinner with isLoading rather than isPending.
Short answer
Diagnostic: Missing queryFn
As of November 2026, the release reference is React Query 5.108.4. isLoading is a derived flag computed from isPending && isFetching (source). When enabled is false, cached data initializes the query in success state.
Choose / don't choose
- Declarative filters: choose
enabledderived from valid filter state; enabling allows normal query lifecycle. - Type-safe omission: choose
skipTokenwhen no valid query function exists before input. - Manual fetch: choose a real query function plus
enabled: false; guard the action's inputs yourself.refetch()can bypass automatic disabling and accepts no new request parameters (source).
Not for: retaining rows during a later filter refresh; see data-table-refetch-loading-state.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
enabled | Default true; derive a boolean conjunction of every required filter's validity, including non-null presence when zero is a valid value | React Query v5 current API | source |
queryKey | Array containing every changing value read by the query function, including filters, page and resource identity where used | React Query v5 | source |
queryFn / skipToken | Use the function only when inputs are valid; otherwise skipToken; use enabled: false for manually triggered queries | React Query v5 current docs | source |
isLoading | isPending && isFetching for the initial spinner; use isFetching separately for later activity | Renamed from isInitialLoading | source |
Order of operations
1. Normalize inputs once. Derive readiness from the actual validity rules; a truthiness check alone may reject a valid numeric zero. 2. Build the key and query function from the same values. For an ID-based request, the example uses enabled: postId != null. Extend that condition to all required inputs. 3. With missing filters, show an instruction to select filters. With a first fetch, show isLoading; with cached data, render the data and any separate refresh indicator. 4. Change a filter and inspect request parameters and the key together; separate combinations must receive separate cache entries (source).
Known failures and fixes
| Error or symptom | Cause | Fix | Source |
|---|---|---|---|
Missing queryFn | refetch() with skipToken has no valid query function | Use enabled: false if manual fetching is required; reject incomplete inputs in that action | source |
isLoading always true with enabled: false (historical symptom) | The migration guide renames loading status to pending | isInitialLoading has been renamed to isLoading | source; source |
Missing
- Required filters and their validation rules depend on the endpoint. Disabling a query is not input validation or access control.
- The old loading-flag report is historical; the v5 migration changes the flag names and meaning.
Checked
2026-11-12; linked sources read. No application commands executed.
Started from a post by @TanStack, packaged by the editor. Original post