main
|
Last change
on this file since 9e9293a was 40ac7a9, checked in by Mihail <mihail2.naumov@…>, 7 months ago |
|
Added frontend elements
|
-
Property mode
set to
100644
|
|
File size:
814 bytes
|
| Line | |
|---|
| 1 | // renderer/usePageContext.tsx
|
|---|
| 2 | import React, { useContext } from 'react';
|
|---|
| 3 |
|
|---|
| 4 | export 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 |
|
|---|
| 17 | const Context = React.createContext<PageContext>(undefined as any);
|
|---|
| 18 |
|
|---|
| 19 | export 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 |
|
|---|
| 29 | export function usePageContext() {
|
|---|
| 30 | const pageContext = useContext(Context);
|
|---|
| 31 | return pageContext;
|
|---|
| 32 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.