Skip to content

V5 queryClient.getQueryData argument is changed to accept only a queryKey #6166

Answered by TkDodo
joel-daros asked this question in Q&A
Discussion options

You must be logged in to vote
queryClient.getQueryCache().find(queryKey, {
  exact: false,
  type: "active",
}

but this approach is quite brittle: if you have multiple active queries, you'll get a "random" one. Also, where do you need getQueryData if not for optimistic updates?

It's best practice to make all parameters that you need to make a query available to all places that need them. This is a "client state management" problem

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@joel-daros
Comment options

@TkDodo
Comment options

@joel-daros
Comment options

@TkDodo
Comment options

Answer selected by joel-daros
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants