({
children,
delay = 500,
})
| 9 | } |
| 10 | |
| 11 | export const DelayRender: React.FC<DelayRenderProps> = ({ |
| 12 | children, |
| 13 | delay = 500, |
| 14 | }) => { |
| 15 | const [shouldRender, setShouldRender] = useState(false); |
| 16 | |
| 17 | useEffect(() => { |
| 18 | const timer = window.setTimeout(() => { |
| 19 | setShouldRender(true); |
| 20 | }, delay); |
| 21 | |
| 22 | return () => { |
| 23 | window.clearTimeout(timer); |
| 24 | }; |
| 25 | }, [delay]); |
| 26 | |
| 27 | return shouldRender ? <>{children}</> : null; |
| 28 | }; |
nothing calls this directly
no test coverage detected