UNPKG

@ima/react-page-renderer

Version:

IMA.js React page renderer.

19 lines (18 loc) 559 B
import { GenericError } from '@ima/core'; import { useContext } from 'react'; import { PageContext } from '../PageContext'; /** * Provides direct access to IMA Page context. * * @example * const pageContext = usePageContext(); * * @returns App page context. */ export function usePageContext() { const context = useContext(PageContext); if (typeof context === 'undefined') { throw new GenericError('The usePageContext hook must be used within PageContext.Provider.'); } return context; } //# sourceMappingURL=pageContext.js.map