UNPKG

@winglet/react-utils

Version:

React utility library providing custom hooks, higher-order components (HOCs), and utility functions to enhance React application development with improved reusability and functionality

15 lines (14 loc) 977 B
import { type ForwardRefExoticComponent, type PropsWithoutRef, type ReactNode, type RefAttributes } from 'react'; import type { Dictionary } from '../../@aileron/declare'; /** * Higher-Order Component (HOC) that wraps a forwardRef component with ErrorBoundary. * Preserves ref forwarding while providing error boundary protection. * @typeParam Props - The component props type * @typeParam Ref - The ref type being forwarded * @param Component - The forwardRef component to wrap * @param fallback - Optional fallback UI to display when an error occurs * @returns A forwardRef component wrapped with ErrorBoundary * @example * const SafeComponent = withErrorBoundaryForwardRef(MyForwardRefComponent, <ErrorFallback />); */ export declare const withErrorBoundaryForwardRef: <Props extends Dictionary, Ref>(Component: ForwardRefExoticComponent<Props & RefAttributes<Ref>>, fallback?: ReactNode) => ForwardRefExoticComponent<PropsWithoutRef<Props> & RefAttributes<Ref>>;