You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using the latest v3 and it's looking great!
I have an interesting use case where a component initiates a mutation but another one needs to know that the mutation is in progress.
I could pass the isLoading all the way down to the other component but the prop drilling wouldn't look good.
For queries there is a useIsFetching hook so I was thinking that a similar idea could be applied for the mutation by creating a useIsMutating hook.
Since now the mutation cache is exposed I could actually create a custom hook, the only challenge was that I didn't have access to some of the utilities functions that are used by the useIsFetching such as:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've been using the latest v3 and it's looking great!
I have an interesting use case where a component initiates a mutation but another one needs to know that the mutation is in progress.
I could pass the
isLoading
all the way down to the other component but the prop drilling wouldn't look good.For queries there is a
useIsFetching
hook so I was thinking that a similar idea could be applied for the mutation by creating auseIsMutating
hook.Since now the mutation cache is exposed I could actually create a custom hook, the only challenge was that I didn't have access to some of the utilities functions that are used by the
useIsFetching
such as:https://github.com/tannerlinsley/react-query/blob/9d66f43d0dc89213112d5aa90076037a9fff6933/src/core/queryClient.ts#L89-L95
It would be great to have this functionality built in by the library.
I'm happy to help with a Pull Request if you think it's a valid idea. Let me know if you want me to elaborate this a bit more 🙂
Beta Was this translation helpful? Give feedback.
All reactions