import * as react_jsx_runtime from 'react/jsx-runtime'; import * as react from 'react'; import { PropsWithChildren, ErrorInfo, ReactNode, FunctionComponent, ComponentProps, ComponentType } from 'react'; import { P as PropsWithoutChildren } from './PropsWithoutChildren-B-UcudRB.js'; type ConstructorType = new (...args: any[]) => TClass; interface ErrorBoundaryFallbackProps { /** * when ErrorBoundary catch error, you can use this error */ error: TError; /** * when you want to reset caught error, you can use this reset */ reset: () => void; } type ShouldCatchCallback = (error: Error) => boolean; type ShouldCatch = ConstructorType | ShouldCatchCallback | boolean; type ErrorBoundaryProps = PropsWithChildren<{ /** * an array of elements for the ErrorBoundary to check each render. If any of those elements change between renders, then the ErrorBoundary will reset the state which will re-render the children */ resetKeys?: unknown[]; /** * when ErrorBoundary is reset by resetKeys or fallback's props.reset, onReset will be triggered */ onReset?: () => void; /** * when ErrorBoundary catch error, onError will be triggered */ onError?: (error: Error, info: ErrorInfo) => void; /** * when ErrorBoundary catch error, fallback will be render instead of children */ fallback: ReactNode | FunctionComponent; /** * determines whether the ErrorBoundary should catch errors based on conditions * @default true */ shouldCatch?: ShouldCatch | [ShouldCatch, ...ShouldCatch[]]; }>; /** * This component provides a simple and reusable wrapper that you can use to wrap around your components. Any rendering errors in your components hierarchy can then be gracefully handled. * @see {@link https://suspensive.org/docs/react/ErrorBoundary Suspensive Docs} */ declare const ErrorBoundary: react.ForwardRefExoticComponent<{ /** * an array of elements for the ErrorBoundary to check each render. If any of those elements change between renders, then the ErrorBoundary will reset the state which will re-render the children */ resetKeys?: unknown[]; /** * when ErrorBoundary is reset by resetKeys or fallback's props.reset, onReset will be triggered */ onReset?: () => void; /** * when ErrorBoundary catch error, onError will be triggered */ onError?: (error: Error, info: ErrorInfo) => void; /** * when ErrorBoundary catch error, fallback will be render instead of children */ fallback: ReactNode | FunctionComponent; /** * determines whether the ErrorBoundary should catch errors based on conditions * @default true */ shouldCatch?: ShouldCatch | [ShouldCatch, ...ShouldCatch[]]; } & { children?: ReactNode | undefined; } & react.RefAttributes<{ reset: () => void; }>> & { displayName: string; with: = Record>(errorBoundaryProps: PropsWithoutChildren | undefined, Component: ComponentType) => ((props: TProps) => react_jsx_runtime.JSX.Element) & { displayName: string; }; Consumer: ({ children }: { children: (errorBoundary: ReturnType) => ReactNode; }) => react_jsx_runtime.JSX.Element; }; /** * This hook provides a simple and reusable wrapper that you can use to wrap around your components. Any rendering errors in your components hierarchy can then be gracefully handled. * @see {@link https://suspensive.org/docs/react/ErrorBoundary#useerrorboundary Suspensive Docs} */ declare const useErrorBoundary: () => { setError: (error: TError) => void; }; /** * This hook allows you to access the reset method and error objects without prop drilling. * @see {@link https://suspensive.org/docs/react/ErrorBoundary#useerrorboundaryfallbackprops Suspensive Docs} */ declare const useErrorBoundaryFallbackProps: () => ErrorBoundaryFallbackProps; export { ErrorBoundary, type ErrorBoundaryFallbackProps, type ErrorBoundaryProps, useErrorBoundary, useErrorBoundaryFallbackProps };