What would be the best way to get multiple mutations statuses?
Hello 👋
What would be the best way to get multiple mutations status?
similar to
https://tanstack.com/query/v4/docs/react/reference/useIsMutating but instead of a number , get an array of the mutations status, of even the entire state. I came up with this hook: https://stackblitz.com/edit/react-ts-jcbyxd?file=useGetMutationsState.ts but I am wondering if there's a simpler way to do such a thing. Also I noticed the type
useIsMutating(filters)https://tanstack.com/query/v4/docs/react/reference/useIsMutating but instead of a number , get an array of the mutations status, of even the entire state. I came up with this hook: https://stackblitz.com/edit/react-ts-jcbyxd?file=useGetMutationsState.ts but I am wondering if there's a simpler way to do such a thing. Also I noticed the type
MutationCacheNotifyEvent cannot be imported from @tanstack/react-query , wondering why?
Thanks in advance:)useIsMutating | TanStack Query Docs
useIsMutating is an optional hook that returns the number of mutations that your application is fetching (useful for app-wide loading indicators).
`tsx
2 Replies
conscious-sapphire•3y ago
This is something you'd need to handle yourself through application state as far as I'm aware. There is the useIsMutating hook (see: https://tanstack.com/query/v4/docs/react/reference/useIsMutating) that returns the number of fetching mutations but it doesn't enable you to identify them.
harsh-harlequinOP•3y ago
Thank you for your response @Louis .
This is what I thought, just wanted to check if there's a proper way to do it.
I think it will make sense to have such a hook that provided the state of multiple mutations/queries similar to the useIsMutating and useIsFetching