import React, { Suspense, memo } from 'react'; import { useLazyWidget } from '@/hooks/useLazyWidget'; import { Skeleton } from '@/components/ui/skeleton'; import { cn } from '@/lib/utils'; interface LazyWidgetProps { children: React.ReactNode; className?: string; fallback?: React.ReactNode; delay?: number; } function WidgetSkeleton({ className }: { className?: string }) { return (
); } export const LazyWidget = memo(function LazyWidget({ children, className, fallback, delay = 0 }: LazyWidgetProps) { const { ref, isVisible, hasLoaded } = useLazyWidget({ delay }); return (
{hasLoaded ? ( }> {children} ) : ( fallback || )}
); });