When passing false as a query key the hook will return isFetching true when no fetching is happening.
The page I'm working on is a search form. On init and form reset searchFormValues is undefined. When the user submits searchFormValues is an object of filter values.
const { data, isFetching } = useQuery(
Boolean(searchFormValues) && ["search", searchFormValues],
fetchSearchResults
);
// isFetching is true until searchFormValues has a value and the request completes.
// This works with useQuery.
const isFetching = status === 'loading'
This becomes more confusing with usePaginatedQuery. isLoading is true on init page load with a falsy query and status remains "success" after the first request completes so neither can be used as a reliable indicator there is a request in process.
When passing false as a query key the hook will return isFetching
truewhen no fetching is happening.The page I'm working on is a search form. On init and form reset searchFormValues is undefined. When the user submits searchFormValues is an object of filter values.
This becomes more confusing with usePaginatedQuery. isLoading is true on init page load with a falsy query and status remains "success" after the first request completes so neither can be used as a reliable indicator there is a request in process.