import React, { startTransition, useEffect } from 'react'; type SftpSidePanelDeferredMountProps = { children: React.ReactNode; ready: boolean; onReady: () => void; }; export const SftpSidePanelDeferredMount: React.FC = ({ children, ready, onReady, }) => { useEffect(() => { if (ready) return; let cancelled = false; const frameId = requestAnimationFrame(() => { if (cancelled) return; startTransition(() => onReady()); }); return () => { cancelled = true; cancelAnimationFrame(frameId); }; }, [ready, onReady]); if (!ready) { return (
Loading…
); } return <>{children}; };