Skip to content
Discussion options

You must be logged in to vote

I think I can answer my own question, don't ;)

The revertState is really the last state of the successful query, so if you first did the query the state will be undefined. I also noticed a bug in the code because I pass around Query objects which get mutated, its safer to extract the data + query key from the list and pass that around instead

export const useUpdateNewsletterCache = () => {
  const queryClient = useQueryClient();
  const queryCache = queryClient.getQueryCache();

  const updateCache = useCallback(
    (newsletterId: Newsletter['id'], updater: (newsletter: Newsletter) => Newsletter) => {
      const previousQueries = queryCache.findAll(QueryKeys.newsletters.all(), { exact: f…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JanStevens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant