0.3.13 • Published 4 years ago
@tylermcrobert/shopify-react v0.3.13
Shopify React
A data controller for Shopify Storefront data.
Initialization
To use the Shopify React plugin, start by wrapping your app in the <CartProvider />
. This provider requires a buy SDK client
.
import { CartProvider, Client } from '@tylermcrobert/shopify-react'
const client = Client.buildClient({
domain: 'my-store.myshopify.com',
accessToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
})
const App = ({ children }) => (
<CartProvider client={client}>
<Cart />
{children}
</CartProvider>
)
Using the Cart
use the useCart
hook to access cart data and state-altering cart methods.
import { useCart } from '@tylermcrobert/shopify-react'
const Cart = ({ children }) => {
const {
addToCart,
cartFetchError,
closeCart,
errorAdding,
isCartOpen,
isLoading,
openCart,
shopifyCheckout,
updateLineItem,
} = useCart()
return <div>Subtotal: ${shopifyCheckout.subtotalPrice}</div>
}
0.3.9
4 years ago
0.3.13
4 years ago
0.3.12
4 years ago
0.3.11
4 years ago
0.3.10
4 years ago
0.3.8
4 years ago
0.3.7
4 years ago
0.3.6
4 years ago
0.3.5
4 years ago
0.3.4
4 years ago
0.3.3
4 years ago
0.3.2
4 years ago
0.3.0
4 years ago
0.3.1
4 years ago
0.2.5
4 years ago
0.2.3
4 years ago
0.2.4
4 years ago
0.2.2
4 years ago
0.1.0
4 years ago
0.2.1
4 years ago
0.0.2
4 years ago
0.0.1
4 years ago