import { createContext, useContext, useMemo, useState, type ReactNode, } from "react"; interface CommandMenuContextType { open: boolean; setOpen: (open: boolean) => void; } const CommandMenuContext = createContext( undefined, ); export function CommandMenuProvider({ children }: { children: ReactNode }) { const [open, setOpen] = useState(false); const value = useMemo(() => { return { open, setOpen }; }, [open]); return ( {children} ); } export function useCommandMenu() { const context = useContext(CommandMenuContext); if (context === undefined) { throw new Error("useCommandMenu must be used within a CommandMenuProvider"); } return context; }