Skip to content

enabled flag for queryClient.prefetchQuery #4791

Answered by TkDodo
anicioalexandre asked this question in Ideas
Discussion options

You must be logged in to vote

The only reason why useQuery has an enabled option is because you can't call it conditionally, as it's a hook. You can just wrap queryClient.prefetchQuery in an if statement and not call it instead.

Also, enabled is an Observer level property, and prefetchQuery doesn't create a QueryObserver - it just fetches data and puts into the cache once.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@anicioalexandre
Comment options

@suryaashish-tyke
Comment options

@TkDodo
Comment options

Answer selected by anicioalexandre
# for free to join this conversation on GitHub. Already have an account? # to comment
Category
Ideas
Labels
None yet
3 participants