Skip to content

Commit

Permalink
add get current snapshot to useOptimisticCartUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasperz committed Jun 3, 2024
1 parent b355057 commit 9e9f418
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/hooks/src/queries/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export const useOptimisticCartUpdate = <Cart extends BarebonesCart>({
const optimisticUpdate = React.useMemo(() => {
let snapshot: Cart | null | undefined = undefined
return {
get: () => snapshot,
update: async (newCart: Cart) => {
await queryClient.cancelQueries(cartQueryKey)
snapshot = queryClient.getQueryData<Cart | null>(cartQueryKey)
Expand Down

0 comments on commit 9e9f418

Please sign in to comment.