Files
supabase/packages/ui-patterns/CommandMenu/internal/Context.tsx
Charis 1b89fa0b5c feat: command menu v2 ui components (#27761)
Co-authored-by: Francesco Sansalvadore <f.sansalvadore@gmail.com>
2024-07-16 14:14:03 -04:00

27 lines
751 B
TypeScript

'use client'
import { createContext, useContext } from 'react'
import { type ICommandsState } from '../internal/state/commandsState'
import { type IPagesState } from '../internal/state/pagesState'
import { type IQueryState } from '../internal/state/queryState'
import { type IViewState } from '../internal/state/viewState'
const CommandContext = createContext<
| {
commandsState: ICommandsState
pagesState: IPagesState
queryState: IQueryState
viewState: IViewState
}
| undefined
>(undefined)
const useCommandContext = () => {
const ctx = useContext(CommandContext)
if (!ctx) throw Error('`useCommandContext` must be used within a `CommandProvider`')
return ctx
}
export { CommandContext, useCommandContext }