Skip to content
Discussion options

You must be logged in to vote

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 true to false, it would refetch. That's why query keys are often considered similar to dependency arrays of useEffect.

Or are there instances where someone needs to construct a queryKey programmatically? What would be an example?

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.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vineetdigit
Comment options

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