@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
14 lines (13 loc) • 718 B
TypeScript
import type { ComponentType, ReactNode } from 'react';
import type { Dictionary } from '../../@aileron/declare';
/**
* Higher-Order Component (HOC) that wraps a component with ErrorBoundary.
* Catches and handles errors that occur within the wrapped component.
* @typeParam Props - The component props type
* @param Component - The component to wrap
* @param fallback - Optional fallback UI to display when an error occurs
* @returns A component wrapped with ErrorBoundary
* @example
* const SafeComponent = withErrorBoundary(MyComponent, <ErrorFallback />);
*/
export declare const withErrorBoundary: <Props extends Dictionary>(Component: ComponentType<Props>, fallback?: ReactNode) => ComponentType<Props>;