Skip to content

Commit

Permalink
Timeout optimistic cart revalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbrasileiro committed Mar 25, 2022
1 parent af8ea6c commit 483383e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/sdk/src/cart/Optimistic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ export const OptimisticProvider = <T extends Item = Item>({

setIsValidating(false)
if (newCart != null) {
setCart(newCart)
setTimeout(() => {
setCart(newCart)
}, 0)
}
}

// Enqueue validation
queue = queue.then(revalidate)
setTimeout(() => {
queue = queue.then(revalidate)
}, 0)

return () => {
cancel = true
Expand Down

0 comments on commit 483383e

Please sign in to comment.