https://dev.kronoz.win/r/marzneshin.git
1import { createContext, useContext } from "react";
2import { SidebarItemGroup } from "./types";
3
4interface SidebarContextProps {
5 sidebar: SidebarItemGroup;
6 collapsed: boolean;
7 setCollapsed: (state: boolean) => void;
8}
9
10export const SidebarContext = createContext<SidebarContextProps | null>(null);
11
12export const useSidebarContext = () => {
13 const ctx = useContext(SidebarContext);
14 if (!ctx)
15 throw new Error('Sidebar.* component must be rendered as child of Sidebar ');
16 return ctx;
17}