import { lazy, Suspense, ComponentType, ReactNode } from 'react'; // Utility to create lazy loaded components with error boundary export function lazyWithPreload>( importFn: () => Promise<{ default: T }> ) { const LazyComponent = lazy(importFn); // Add preload method (LazyComponent as any).preload = importFn; return LazyComponent; } // Default loading component const DefaultLoader = () => (
); // Wrapper component with loading fallback export function LazyLoad({ component: Component, fallback = , ...props }: { component: ComponentType; fallback?: ReactNode; [key: string]: any; }) { return ( ); } // Preload components on hover/focus export function preloadComponent(component: any) { if (component.preload) { component.preload(); } }