dm_new menu
This commit is contained in:
@@ -2,7 +2,7 @@ export { getCookie, setCookie, removeCookie } from "./cookie";
|
||||
// export { useMutationWrapper } from "./use-mutation-wrapper";
|
||||
// export { useAlertStore } from "./use-alert-store";
|
||||
// export { useDataTable } from "./use-data-table";
|
||||
// export { useMenuStore } from "./use-menu-store";
|
||||
export { useMenuStore } from "./use-menu-store";
|
||||
// export { useUserStore } from "./use-user-store";
|
||||
// export { usePrompt } from "./use-prompt";
|
||||
// export { useSelectPrompt } from "./use-select-prompt";
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { useStore } from "zustand";
|
||||
import { useContext } from "react";
|
||||
import type { MenuStore } from "../store/menu-store";
|
||||
import { StoreContext } from "../providers/store-provider";
|
||||
|
||||
export const useMenuStore = <T>(selector: (store: MenuStore) => T): T => {
|
||||
const storeContext = useContext(StoreContext);
|
||||
|
||||
if (!storeContext) {
|
||||
throw new Error("useMenuStore must be used within StoreProvider");
|
||||
}
|
||||
|
||||
return useStore(storeContext.menuStore, selector);
|
||||
};
|
||||
Reference in New Issue
Block a user