import { createContext, useContext } from 'octane'; import type { QueryErrorResetBoundaryValue } from './types'; export type { QueryErrorResetBoundaryValue }; export function createValue(): QueryErrorResetBoundaryValue { let isReset = false; return { clearReset: () => { isReset = false; }, reset: () => { isReset = true; }, isReset: () => isReset, }; } // The reset coordinator for error-boundary retries. While "reset", a thrown query // error is NOT re-thrown (so the boundary's retry refetches instead of looping). // The default value means: without a ``, `isReset()` is // always false — identical to having no boundary. export const QueryErrorResetBoundaryContext = createContext(createValue()); export function useQueryErrorResetBoundary(): QueryErrorResetBoundaryValue { return useContext(QueryErrorResetBoundaryContext); }