Skip to content

status === 'loading' when queryKey is falsey #170

@benmonro

Description

@benmonro

when using a 'lazy' query (i.e. passing in a falsey value for the queryKey), the status is indefinitely set to "loading." even though the status will never change from that, this can cause bugs in the UI where folks will be rendering a spinner. Seems to make more sense to have status default to 'success' if the queryKey is falsey and only be 'loading' when the key is truthy.

i.e.

const {status} = useQuery(false && myKey, fetcher)

status === "success"

const {status} = useQuery(true && myKey, fetcher)

status === "loading"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions