We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a1ed746 commit 06fe4f7Copy full SHA for 06fe4f7
src/hooks/useCart.ts
@@ -185,9 +185,10 @@ export function useApplyDiscountCode() {
185
mutationKey: CART_MUTATION_KEY,
186
mutationFn: (input: { code: string }) =>
187
applyDiscountCode({ data: { code: input.code } }),
188
+ onMutate: async () => {
189
+ await qc.cancelQueries({ queryKey: CART_QUERY_KEY })
190
+ },
191
onSuccess: (cart) => {
- // Discount apply has no optimistic state, so setting server
- // response here is safe — it only adds information.
192
qc.setQueryData(CART_QUERY_KEY, cart)
193
},
194
onSettled: () => settleWhenIdle(qc),
0 commit comments