Skip to content

Framer motion & React 18 #909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions components/Cart/AddToCartButton.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const AddToCartButton = ({ product }) => {
const { data, refetch } = useQuery(GET_CART, {
notifyOnNetworkStatusChange: true,
onCompleted: () => {
refetch();
// Update cart in the localStorage.
const updatedCart = getFormattedCart(data);

Expand All @@ -54,12 +55,14 @@ const AddToCartButton = ({ product }) => {
input: productQueryInput,
},
onCompleted: () => {
console.log("Completed")
// Update the cart with new values in React context.
refetch();
// If error.
if (addToCartError) {
setRequestError(addToCartError.graphQLErrors[0].message);
}
// Update the cart with new values in React context.
refetch();

// Show View Cart Button
setShowViewCart(true);
setshowAddToCart(true);
Expand All @@ -74,6 +77,7 @@ const AddToCartButton = ({ product }) => {
const handleAddToCartClick = () => {
setRequestError(null);
addToCart();
refetch();
};

// Separate out conditions here for increased readability
Expand Down
2 changes: 2 additions & 0 deletions components/Cart/CartPage/CartItem.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const CartItem = ({
});
}
}

refetch();
};
return (
<tr className="bg-gray-100">
Expand Down
4 changes: 4 additions & 0 deletions components/Cart/CartPage/CartItemsContainer.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const CartItemsContainer = () => {
const { data, refetch } = useQuery(GET_CART, {
notifyOnNetworkStatusChange: true,
onCompleted: () => {
refetch();

// Update cart in the localStorage.
const updatedCart = getFormattedCart(data);
localStorage.setItem('woocommerce-cart', JSON.stringify(updatedCart));
Expand Down Expand Up @@ -71,6 +73,8 @@ const CartItemsContainer = () => {
},
});
}

refetch();
};

useEffect(() => {
Expand Down
Loading