zustand store
This commit is contained in:
23
lib/productZustand.ts
Normal file
23
lib/productZustand.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { create } from "zustand";
|
||||||
|
import { devtools, persist } from "zustand/middleware";
|
||||||
|
|
||||||
|
interface ProductStore {
|
||||||
|
productName: string;
|
||||||
|
setProductName: (name: string) => void;
|
||||||
|
resetProductName: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useProductStore = create<ProductStore>()(
|
||||||
|
devtools(
|
||||||
|
persist(
|
||||||
|
(set) => ({
|
||||||
|
productName: "",
|
||||||
|
setProductName: (name: string) => set({ productName: name }),
|
||||||
|
resetProductName: () => set({ productName: "" }),
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
name: "product-storage",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user