@ima/react-page-renderer
Version:
IMA.js React page renderer.
19 lines (18 loc) • 559 B
JavaScript
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