Queries with additional parameter #2365
-
|
I am trying to understand how the additional parameters to the query string are used and for what purpose. Is the purpose of using additional parameters only for uniquely identifying the query in the devtools? Following example passes {preview: true} option. And this very well could be replaced by string Or are there instances where someone needs to construct a queryKey programmatically? What would be an example? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
queryKeys are used to uniquely identify a query. react-query also triggers a refetch if a query key changes for a query. If preview goes from
if you want to invalidate a specific query, or want to do updates on a specific query with |
Beta Was this translation helpful? Give feedback.
queryKeys are used to uniquely identify a query. react-query also triggers a refetch if a query key changes for a query. If preview goes from
truetofalse, it would refetch. That's why query keys are often considered similar to dependency arrays of useEffect.if you want to invalidate a specific query, or want to do updates on a specific query with
queryClient.setQueryData, you need to construct the query key.