diff options
| author | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-09-21 14:56:35 +0700 |
|---|---|---|
| committer | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-09-21 14:56:35 +0700 |
| commit | 4f285349adec93a040e41d1d8c0c1c7b57749397 (patch) | |
| tree | 48d3f47c42f65a58b3a24c99410a52ade3f313ea /src/contexts/ProductCartContext.js | |
| parent | 54b3b9670995d62c2e11b761911430e4300fa36e (diff) | |
add context for list product popup cart
Diffstat (limited to 'src/contexts/ProductCartContext.js')
| -rw-r--r-- | src/contexts/ProductCartContext.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/contexts/ProductCartContext.js b/src/contexts/ProductCartContext.js new file mode 100644 index 00000000..06e97563 --- /dev/null +++ b/src/contexts/ProductCartContext.js @@ -0,0 +1,21 @@ +import { createContext, useCallback, useContext, useEffect, useState } from 'react' + +const ProductCartContext = createContext() + +export const ProductCartProvider = ({ children }) => { + const [productCart, setProductCart] = useState(null) + const [refreshCart, setRefreshCart] = useState(false) + const [isLoading, setIsloading] = useState(false) + + return ( + <ProductCartContext.Provider + value={{ productCart, setProductCart, refreshCart, setRefreshCart, isLoading, setIsloading }} + > + {children} + </ProductCartContext.Provider> + ) +} + +export const useProductCartContext = () => { + return useContext(ProductCartContext) +} |
