setQueryData with exact option
I would like to use
setQueryData with an option exact. For example I have a key 123 that can have multiple variants 123-A, 123-B etc. and I would like to update all keys that contain 123. Is that in any way possible?4 Replies
passive-yellowOP•3y ago
Im not using
queryClient.getQueryCache().getAll() and looping through the keys, not sure if thats the best solutionfascinating-indigo•3y ago
Hi 👋
I think you're looking for
setQueriesData. It searches inclusively by default, can update multiple queries, and also has an exact option.
See: https://tanstack.com/query/latest/docs/react/reference/QueryClient?from=reactQueryV3&original=https%3A%2F%2Freact-query-v3.tanstack.com%2Freference%2FQueryClient#queryclientsetqueriesdata and https://tanstack.com/query/latest/docs/react/guides/filters#query-filterspassive-yellowOP•3y ago
Nice. Thank you
fascinating-indigo•3y ago
No problem :reactquery: