source: renderer/usePageContext.tsx@ 6270fa4

main
Last change on this file since 6270fa4 was 40ac7a9, checked in by Mihail <mihail2.naumov@…>, 7 months ago

Added frontend elements

  • Property mode set to 100644
File size: 814 bytes
RevLine 
[40ac7a9]1// renderer/usePageContext.tsx
2import React, { useContext } from 'react';
3
4export type PageContext = {
5 Page: any;
6 pageProps?: any;
7 urlPathname: string;
8 exports: {
9 documentProps?: {
10 title?: string;
11 description?: string;
12 };
13 };
14 session?: any;
15};
16
17const Context = React.createContext<PageContext>(undefined as any);
18
19export function PageContextProvider({
20 pageContext,
21 children,
22 }: {
23 pageContext: PageContext;
24 children: React.ReactNode;
25}) {
26 return <Context.Provider value={pageContext}>{children}</Context.Provider>;
27}
28
29export function usePageContext() {
30 const pageContext = useContext(Context);
31 return pageContext;
32}
Note: See TracBrowser for help on using the repository browser.