({ children }: { children: ReactNode })
| 60 | const PageContextContext = createContext<PageContextValue | null>(null); |
| 61 | |
| 62 | export 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 | |
| 83 | function useInternalPageContext(): PageContextValue { |
| 84 | const value = useContext(PageContextContext); |
nothing calls this directly
no outgoing calls
no test coverage detected