Tracking mutations via mutation cache?
Example: Have a row of records that could potentially have different mutations apply to them. Mutations can get called on these rows by a context menu that unrenders.
If I wanted to track the state of each of the rows and their related mutation, am I better manually tracking an array of Id's with error and loading states., or subscribing in a row component to the mutation cache?
3 Replies
rare-sapphire•8mo ago
I believe the simplest approach would be to use individual mutation keys for each row, which means that the
id should be baked into the mutationFn and not a parameter of the mutationFn. For example:
Then in your component:
other-emeraldOP•7mo ago
brilliant and simple, this is what I needed thank you.
like-gold•7mo ago
You can also use the
useMutationState to get the state of any mutation via mutationKey