TanStackT
TanStack13mo ago
2 replies
then-purple

Best way to persists running mutations across mounts

Im running a mutation inside a "dialog" -, if the user closes the dialog, and then re-opens it, the mutation pending state is lost, which is to be expected.

But what is best practice to handle such situations? I have experimented with various apporaches such as:
- Setting a mutation key, and reading state using useMutationState in a sperate hook
- Setting a mutation key, returning a different isPending boolean

The two apporaches mainly differs in having one hook, or two hooks.

Also. If i has a scope-id -, should the pending state persists across mounts/umounts? I would findt that intuitive, due to the its nature of not allowing more than one mutation running at a time anyways.
Was this page helpful?