Skip to content

enabled flag for queryClient.prefetchQuery #4791

Answered by TkDodo
anicioalexandre asked this question in Ideas

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

You must be logged in to vote
3 replies
@anicioalexandre

@suryaashish-tyke

@TkDodo

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