Skip to content

isFetching true on falsy query #360

@JaminFarr

Description

@JaminFarr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions