import React from 'react'; declare type ErrorHandler = (error: Error, info: React.ErrorInfo) => void; declare type ErrorHandlingComponent = (props: Props, error?: Error) => React.ReactNode; /** * 允许使用函数组件作为错误边界捕获组件 * @param component 处理错误边界的函数组件 * @param errorHandler 错误后用于处理其他副作用,例如日志 * @example * ```tsx const MyErrorBoundary = Catch((props: Props, error?: Error) => { if (error) { return (

An error has occured

{error.message}

) } else { return {props.children} } }) ``` */ export declare const Catch: (component: ErrorHandlingComponent, errorHandler?: ErrorHandler) => React.ComponentType; export default Catch;