migrated to vite and vite-plugin-ssr

This commit is contained in:
Ren Amamiya
2023-04-22 17:56:09 +07:00
parent c50e507c14
commit b9bafc851e
67 changed files with 911 additions and 1060 deletions

View File

@@ -0,0 +1,22 @@
// `usePageContext` allows us to access `pageContext` in any React component.
// See https://vite-plugin-ssr.com/pageContext-anywhere
import type { PageContext } from '@renderer/types';
import { createContext, useContext } from 'react';
const Context = createContext<PageContext>(undefined as any);
export function PageContextProvider({
pageContext,
children,
}: {
pageContext: PageContext;
children: React.ReactNode;
}) {
return <Context.Provider value={pageContext}>{children}</Context.Provider>;
}
export function usePageContext() {
const pageContext = useContext(Context);
return pageContext;
}