Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 20, 2023. It is now read-only.

Commit 21c5f93

Browse files
removed redudant or unused code
1 parent dc25c14 commit 21c5f93

File tree

3 files changed

+24
-30
lines changed

3 files changed

+24
-30
lines changed

‎reactHooks-redux-js-buy/src/components/Cart.js‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,6 @@ export default (props) => {
1212
setCount,
1313
} = useShopify()
1414

15-
function getCount() {
16-
let lineItems =
17-
checkoutState.lineItems && checkoutState.lineItems.length > 0
18-
? checkoutState.lineItems
19-
: []
20-
let count = 0
21-
lineItems.forEach((item) => {
22-
count += item.quantity
23-
return count
24-
})
25-
26-
setCount(count)
27-
}
28-
2915
function handleOpen(e) {
3016
e.preventDefault()
3117
openCart()
@@ -49,6 +35,21 @@ export default (props) => {
4935
} else {
5036
button.classList.remove("hide")
5137
}
38+
39+
function getCount() {
40+
let lineItems =
41+
checkoutState.lineItems && checkoutState.lineItems.length > 0
42+
? checkoutState.lineItems
43+
: []
44+
let count = 0
45+
lineItems.forEach((item) => {
46+
count += item.quantity
47+
return count
48+
})
49+
50+
setCount(count)
51+
}
52+
5253
getCount()
5354
}, [cartStatus, checkoutState])
5455

‎reactHooks-redux-js-buy/src/components/Products.js‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
import React,{useEffect} from "react"
1+
import React from "react"
22
import Product from "./Product"
3-
import { useShopify } from "../hooks"
43

54
export default (props) => {
6-
const { fetchProducts } = useShopify()
7-
8-
useEffect(() => {
9-
fetchProducts()
10-
}, [])
11-
125
return (
136
<div className="Products-wrapper">
147
<Product history={props.history} />

‎reactHooks-redux-js-buy/src/redux/ducks/shopify/index.js‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ import Client from "shopify-buy"
33

44
// Creates the client with Shopify-Buy and store info
55
//
6-
const client = Client.buildClient({
7-
storefrontAccessToken: "your-storefront-access-token",
8-
domain: "your-shop-name.myshopify.com",
9-
})
6+
// const client = Client.buildClient({
7+
// storefrontAccessToken: "your-storefront-access-token",
8+
// domain: "your-shop-name.myshopify.com",
9+
// })
1010

1111
//
1212
// Example Storefront
1313
//
14-
// const client = Client.buildClient({
15-
// storefrontAccessToken: "dd4d4dc146542ba7763305d71d1b3d38",
16-
// domain: "graphql.myshopify.com",
17-
// })
14+
const client = Client.buildClient({
15+
storefrontAccessToken: "dd4d4dc146542ba7763305d71d1b3d38",
16+
domain: "graphql.myshopify.com",
17+
})
1818

1919
const PRODUCTS_FOUND = "shopify/PRODUCTS_FOUND"
2020
const PRODUCT_FOUND = "shopify/PRODUCT_FOUND"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /