Problem: I want to show a spinner if any React Query mutations are in progress
Problem: I want to show a spinner if any React Query mutations are in progress.
Solution: useIsMutating. This hook returns true if any mutations are running.
Problem: I want to show multiple spinners, depending on which mutations are pending.
Solution: useMutationState. This hook returns data about which mutations are in progress.
I just used useMutationState to replace a specific button on the page with a loading spinner when a corresponding useMutation call is in progress.
More here: https://tanstack.com/query/latest/docs/framework/react/reference/useMutationState