(urls: string[])
| 10 | * Uses requestIdleCallback to avoid blocking critical rendering. |
| 11 | */ |
| 12 | export function useImagePreloader(urls: string[]): void { |
| 13 | useEffect(() => { |
| 14 | const load = () => urls.forEach(preloadImage); |
| 15 | |
| 16 | // Use requestIdleCallback if available, otherwise setTimeout as fallback |
| 17 | if (typeof requestIdleCallback !== 'undefined') { |
| 18 | const handle = requestIdleCallback(load); |
| 19 | return () => { |
| 20 | cancelIdleCallback(handle); |
| 21 | }; |
| 22 | } |
| 23 | |
| 24 | const handle = setTimeout(load, 1); |
| 25 | return () => { |
| 26 | clearTimeout(handle); |
| 27 | }; |
| 28 | }, [urls]); |
| 29 | } |
nothing calls this directly
no outgoing calls
no test coverage detected