Files
supabase/packages/ui-patterns/CommandMenu/internal/Context.tsx
Jordi Enric 6f1cfef213 clean circular deps (#34262)
* clean circular deps in telemetry

* clean circular deps in command

* fix commandmenu circular deps

* rm deps.json

* fix consent circular dep

* fix TOC circular deps

* fix wrong import path

* fix test types

* fix missing fn

* undo let change

* fix consent component

* empty
2025-03-20 11:11:11 +01:00

27 lines
743 B
TypeScript

'use client'
import { createContext, useContext } from 'react'
import { type ICommandsState } from '../internal/types'
import { type IPagesState } from '../internal/state/pagesState'
import { type IQueryState } from '../internal/state/queryState'
import { type IViewState } from '../internal/state/viewState.types'
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 }