import { isDevMode } from "@/lib/utils/env"; import type { Dispatch, ReactNode, SetStateAction } from "react"; import { createContext, useContext, useState } from "react"; interface DebugContextValue { showStackHeader: boolean; setShowStackHeader: Dispatch>; } const DebugContext = createContext(null); export const useDebugState = () => { const value = useContext(DebugContext); if (!value) throw new Error( "Debug provider failed to initialise. Did you access this out of tree somehow? Tried to access debug value before it was initialised.", ); return value; }; export const DebugProvider = ({ children }: { children: ReactNode }) => { const [showStackHeader, setShowStackHeader] = useState(false); const value: DebugContextValue = { showStackHeader, setShowStackHeader, }; return {children}; };