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
24 lines (19 loc) • 710 B
text/typescript
import {useContext} from 'react'
import {PresentationParamsContext} from 'sanity/_singletons'
import {type PresentationParamsContextValue} from './types'
/** @public */
export function usePresentationParams(throwOnMissingContext?: true): PresentationParamsContextValue
/** @public */
export function usePresentationParams(
throwOnMissingContext: false,
): PresentationParamsContextValue | null
/** @public */
export function usePresentationParams(
throwOnMissingContext = true,
): PresentationParamsContextValue | null {
const params = useContext(PresentationParamsContext)
if (throwOnMissingContext && !params) {
throw new Error('Presentation params context is missing')
}
return params
}