MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / PageContextProvider

Function PageContextProvider

apps/start/src/contexts/page-context.tsx:62–81  ·  view source on GitHub ↗
({ children }: { children: ReactNode })

Source from the content-addressed store, hash-verified

60const PageContextContext = createContext<PageContextValue | null>(null);
61
62export function PageContextProvider({ children }: { children: ReactNode }) {
63 const [context, setContextState] = useState<PageContext | null>(null);
64 const ref = useRef<PageContext | null>(null);
65
66 const setContext = useCallback((ctx: PageContext | null) => {
67 ref.current = ctx;
68 setContextState(ctx);
69 }, []);
70
71 const value = useMemo(
72 () => ({ context, setContext, ref }),
73 [context, setContext],
74 );
75
76 return (
77 <PageContextContext.Provider value={value}>
78 {children}
79 </PageContextContext.Provider>
80 );
81}
82
83function useInternalPageContext(): PageContextValue {
84 const value = useContext(PageContextContext);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected