Download next.js/test/e2e/app-dir/app-prefetch/app/invalid-url/delay.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 389 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/app-prefetch/app/invalid-url/delay.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/e2e/app-dir/app-prefetch/app/invalid-url/delay.js
-
curl -L -o delay.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/app-prefetch/app/invalid-url/delay.js
389 Bytes
| 'use client' | |
| import { useEffect } from 'react' | |
| import { useState } from 'react' | |
| export function Delay({ duration = 500, children }) { | |
| const [isVisible, setIsVisible] = useState(false) | |
| useEffect(() => { | |
| const timeout = setTimeout(() => setIsVisible(true), duration) | |
| return () => clearTimeout(timeout) | |
| }, [duration]) | |
| if (!isVisible) return null | |
| return <>{children}</> | |
| } | |