import "react"; //#region src/internal.d.ts /** Boundary information: [boundaryId, BoundaryComponent] */ type BoundaryInfo = [string, React.ComponentType]; /** For internal use only */ //#endregion //#region src/index.d.ts /** * Returns information about all boundary components above this component * * Returns an array of [boundaryId, BoundaryComponent] tuples, * ordered from outermost to innermost boundary. * If not set manually, boundaryId format is file.tsx:line * * Returns empty array if no boundaries are found. * * @dev In development mode, this hook provides React DevTools debug information * showing the boundary hierarchy as "Component Names → Stack IDs" for easier debugging. * This debug output is automatically stripped in production builds. */ declare const useBoundaryStack: () => BoundaryInfo[]; /** * Returns information about the nearest boundary above this component * * If not set manually the format is file.tsx:line * * Returns null if no boundary is found. */ declare const useSuspenseOwner: () => string | null; /** * Throws if this component might suspend but has no Suspense boundary above it * in development mode only. * * In production mode, it does nothing * * For production use useSuspenseOwner instead which returns null if no * Suspense boundary is found */ declare const useThrowIfSuspenseMissing: (skip?: boolean) => void; /** * Wraps a hook to catch Suspense errors and call the provided onSuspense function * with the current boundary information. * * @param hook - The hook to wrap. * @param onSuspense - Function to call when a Suspense error occurs. * @param onlySuspense - If true, only Suspense boundaries will be included in the stack - defaults to true * @returns A wrapped version of the hook * * * Usage: * ```tsx * import { useQuery } from 'react-query'; * import { wrapSuspendableHook } from 'suspense-tracker'; * * const useQueryWithDebug = wrapSuspendableHook( * useQuery, * (suspenseBoundaryStack, queryKey) => { * if (suspenseBoundaryStack.length === 0) { * console.warn(`No boundary found for query: ${queryKey}`); * } else { * console.info(`Suspense from query: ${queryKey} triggered in ${suspenseBoundaryStack[0]}`); * } * } * ); * * function MyComponent() { * const { data } = useQueryWithDebug('my-query-key', fetchData); * return
{data}
; * } * ``` */ declare const wrapSuspendableHook: any>(hook: T, /** Called if the hook suspends */ onSuspense: (...args: NoInfer<[string[], ...Parameters]>) => void, onlySuspense?: boolean) => T; //#endregion export { useBoundaryStack, useSuspenseOwner, useThrowIfSuspenseMissing, wrapSuspendableHook };