'use client'; import { useEffect, useState } from 'react'; const Preloader = () => { const [isLoading, setIsLoading] = useState(true); useEffect(() => { // Simulate loading time or wait for window load const handleLoad = () => { // Add a small delay to ensure assets are loaded or at least a smooth transition setTimeout(() => { setIsLoading(false); }, 500); }; if (document.readyState === 'complete') { handleLoad(); } else { window.addEventListener('load', handleLoad); // Fallback in case load event already fired or takes too long const timeoutId = setTimeout(handleLoad, 3000); return () => { window.removeEventListener('load', handleLoad); clearTimeout(timeoutId); }; } }, []); if (!isLoading) return null; return (
Loading