MCPcopy Create free account
hub / github.com/dailydotdev/apps / useImagePreloader

Function useImagePreloader

packages/shared/src/hooks/useImagePreloader.ts:12–29  ·  view source on GitHub ↗
(urls: string[])

Source from the content-addressed store, hash-verified

10 * Uses requestIdleCallback to avoid blocking critical rendering.
11 */
12export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected