Skip to content

Commit c1f6c58

Browse files
committed
Remove beta version of Apollo 3.0
1 parent 8af2c41 commit c1f6c58

File tree

7 files changed

+34
-62
lines changed

7 files changed

+34
-62
lines changed

components/Cart/AddToCartButton.component.jsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { request } from 'graphql-request';
33
import useSWR from 'swr';
44
import { v4 as uuidv4 } from 'uuid';
55

6-
import { useQuery, useMutation } from '@apollo/client';
6+
import { useQuery, useMutation } from '@apollo/react-hooks';
77

88
import { AppContext } from 'utils/context/AppContext';
99

@@ -37,26 +37,21 @@ const AddToCartButton = (props) => {
3737
productId: product.productId,
3838
};
3939

40-
41-
// Get Cart Data.
42-
const { loading, error, data, refetch } = useQuery( GET_CART, {
43-
notifyOnNetworkStatusChange: true,
44-
onCompleted: () => {
45-
46-
console.log("Data from add to cart button: ");
40+
// Get Cart Data.
41+
const { loading, error, data, refetch } = useQuery(GET_CART, {
42+
notifyOnNetworkStatusChange: true,
43+
onCompleted: () => {
44+
console.log('Data from add to cart button: ');
4745
console.log(data);
48-
// Update cart in the localStorage.
49-
const updatedCart = getFormattedCart( data );
50-
46+
// Update cart in the localStorage.
47+
const updatedCart = getFormattedCart(data);
5148

52-
localStorage.setItem( 'woocommerce-cart', JSON.stringify( updatedCart ) );
49+
localStorage.setItem('woocommerce-cart', JSON.stringify(updatedCart));
5350

54-
// Update cart data in React Context.
55-
setCart( updatedCart );
56-
57-
}
58-
} );
59-
51+
// Update cart data in React Context.
52+
setCart(updatedCart);
53+
},
54+
});
6055

6156
const [
6257
addToCart,

components/Cart/CartPage/CartItemsContainer.component.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Link from 'next/link';
22
import { v4 } from 'uuid';
33
import { useContext, useState, useEffect } from 'react';
44

5-
import { useQuery, useMutation } from '@apollo/client';
5+
import { useQuery, useMutation } from '@apollo/react-hooks';
66

77
import { AppContext } from 'utils/context/AppContext';
88
import {

components/Checkout/CheckoutForm.component.jsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import { useState, useContext, useEffect } from 'react';
2-
import { useQuery, useMutation } from '@apollo/client';
2+
import { useQuery, useMutation } from '@apollo/react-hooks';
33

44
import { GET_CART } from 'utils/const/GQL_QUERIES';
55
import { INITIAL_STATE } from 'utils/const/INITIAL_STATE';
66
import { AppContext } from 'utils/context/AppContext';
77

8-
import {
9-
getFormattedCart,
10-
getUpdatedItems,
11-
removeItemFromCart,
12-
} from 'utils/functions/functions';
8+
import { getFormattedCart } from 'utils/functions/functions';
139

1410
const CheckoutForm = () => {
1511
const [cart, setCart] = useContext(AppContext);
@@ -50,7 +46,7 @@ const CheckoutForm = () => {
5046

5147
useEffect(() => {
5248
if (null !== orderData) {
53-
// Call the checkout mutation when the value for orderData changes/updates.
49+
// Do checkout mutation when the value for orderData changes.
5450
// checkout();
5551
}
5652
}, [orderData]);

package-lock.json

Lines changed: 15 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"author": "",
1313
"license": "ISC",
1414
"dependencies": {
15-
"@apollo/client": "^3.0.0-rc.2",
15+
"@apollo/react-hooks": "^3.1.5",
1616
"algoliasearch": "^4.2.0",
1717
"apollo-boost": "^0.4.9",
1818
"apollo-cache-inmemory": "^1.6.6",

pages/_app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ApolloProvider } from '@apollo/client';
1+
import { ApolloProvider } from '@apollo/react-hooks';
22

33
import { AppProvider } from 'utils/context/AppContext';
44

pages/index.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ export async function getServerSideProps() {
4747
query: FETCH_ALL_PRODUCTS_QUERY,
4848
});
4949

50-
//console.log("getServerSideProps data: ")
51-
//console.log(data)
52-
console.log('getServerSideProps networkStatus: ');
53-
console.log(networkStatus);
54-
console.log('getServerSideProps loading: ');
55-
console.log(loading);
56-
5750
return {
5851
props: {
5952
// products: result.data.products.nodes,

0 commit comments

Comments
 (0)