UNPKG

sanity

Version:

Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches

17 lines (12 loc) 624 B
import {useContext} from 'react' import {PresentationContext} from 'sanity/_singletons' import {type PresentationContextValue} from './types' export function usePresentationTool(throwOnMissingContext?: true): PresentationContextValue export function usePresentationTool(throwOnMissingContext: false): PresentationContextValue | null export function usePresentationTool(throwOnMissingContext = true): PresentationContextValue | null { const presentation = useContext(PresentationContext) if (throwOnMissingContext && !presentation) { throw new Error('Presentation context is missing') } return presentation }