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
In our current codebase we are rewriting a lot of logic that goes something along the lines of this;
constuseExampleMutation=()=>{returnuseMutation({mutationFn: ()=>{returnPromise.resolve()},onMutate: ()=>{return{currency: getCurrencyFromStorage(),}},onSuccess: (_data,_variables,context)=>{console.log(`User completed mutation in ${context.currency}`)},})}
Instead of this I'd like a way of extending the context so that all mutations can access the currency in which the mutation was created with. Initially I believed this would have been quite easy using the MutationCache and extending the onMutate function. However this does not work.
What would be the tanstack way of creating a shared context for all our mutations?
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
-
In our current codebase we are rewriting a lot of logic that goes something along the lines of this;
Instead of this I'd like a way of extending the context so that all mutations can access the currency in which the mutation was created with. Initially I believed this would have been quite easy using the
MutationCache
and extending theonMutate
function. However this does not work.What would be the tanstack way of creating a shared context for all our mutations?
Beta Was this translation helpful? Give feedback.
All reactions