diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-09-15 09:15:54 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-09-15 09:15:54 +0700 |
| commit | f90ec98c509fad7146c169d8d762b4c847d07af8 (patch) | |
| tree | ed7bf1192b580503ca4246221590abe2566781fb /src/contexts | |
| parent | ce8a2e4ed9534d6fd5c1d8734aa06f51426101cd (diff) | |
Add product context provider
Diffstat (limited to 'src/contexts')
| -rw-r--r-- | src/contexts/ProductContext.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/contexts/ProductContext.js b/src/contexts/ProductContext.js new file mode 100644 index 00000000..7bf65989 --- /dev/null +++ b/src/contexts/ProductContext.js @@ -0,0 +1,15 @@ +import { createContext, useContext, useState } from 'react' + +const ProductContext = createContext() + +export const ProductProvider = ({ children }) => { + const [product, setProduct] = useState(null) + + return ( + <ProductContext.Provider value={{ product, setProduct }}>{children}</ProductContext.Provider> + ) +} + +export const useProductContext = () => { + return useContext(ProductContext) +} |
