The complete debug context value.
export function useDebug(): DebugContextType {
const legacyContext = useContext(DebugContext);
const stateContext = useContext(DebugStateContext);
const actionsContext = useContext(DebugActionsContext);
const mergedContext = React.useMemo(() => {
if (legacyContext !== undefined) {
return legacyContext;
}
if (stateContext !== undefined && actionsContext !== undefined) {
return {
...stateContext,
...actionsContext,
} satisfies DebugContextType;
}
return undefined;
}, [actionsContext, legacyContext, stateContext]);
if (mergedContext === undefined) {
throw new Error("useDebug must be used within a DebugProvider");
}
return mergedContext;
}
Hook to access complete debug context (both state and actions combined). Prefers split contexts but falls back to legacy unified context for backward compatibility. Use
useDebugStateoruseDebugActionsseparately when possible for better performance.