Skip to content

Commit 2a81bf7

Browse files
author
Daniel Fjeldstad
committed
Refetch cart on page load
1 parent b6778da commit 2a81bf7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

components/Cart/CartPage/CartItemsContainer.component.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Link from 'next/link';
22
import { v4 as uuidv4 } from 'uuid';
3-
import { useContext, useState } from 'react';
3+
import { useContext, useState, useEffect } from 'react';
44
import { useQuery, useMutation } from '@apollo/client';
55

66
import { AppContext } from 'utils/context/AppContext';
@@ -72,6 +72,10 @@ const CartItemsContainer = () => {
7272
}
7373
};
7474

75+
useEffect(() => {
76+
refetch();
77+
}, []);
78+
7579
return (
7680
<>
7781
<section className="py-8 bg-white">

components/Checkout/CheckoutForm.component.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ const CheckoutForm = () => {
5858
}
5959
}, [orderData]);
6060

61+
useEffect(() => {
62+
refetch();
63+
}, []);
64+
6165
const onSubmit = (submitData) => {
6266
const checkOutData = createCheckoutData(submitData);
6367
setOrderData(checkOutData);

0 commit comments

Comments
 (0)