···26 // Do things that are absolutely necessary and logic related (like query invalidation) in the useMutation callbacks
27 // Do UI related things like redirects or showing toast notifications in mutate callbacks. If the user navigated away from the current screen before the mutation finished, those will purposefully not fire
28 // https://tkdodo.eu/blog/mastering-mutations-in-react-query#some-callbacks-might-not-fire
29- onSuccess: () => {
30 queryClient.invalidateQueries({ queryKey: ['my cards'] });
000000031 },
32 });
33
···26 // Do things that are absolutely necessary and logic related (like query invalidation) in the useMutation callbacks
27 // Do UI related things like redirects or showing toast notifications in mutate callbacks. If the user navigated away from the current screen before the mutation finished, those will purposefully not fire
28 // https://tkdodo.eu/blog/mastering-mutations-in-react-query#some-callbacks-might-not-fire
29+ onSuccess: (_data, variables) => {
30 queryClient.invalidateQueries({ queryKey: ['my cards'] });
31+ queryClient.invalidateQueries({ queryKey: ['library'] });
32+ queryClient.invalidateQueries({ queryKey: ['collections'] });
33+34+ // invalidate each collection query individually
35+ variables.collectionIds?.forEach((id) => {
36+ queryClient.invalidateQueries({ queryKey: ['collection', id] });
37+ });
38 },
39 });
40