Files
cinny/src/app/hooks/useObjectURL.ts
T
litruv a6ad8651b3
Checks / checks (push) Successful in 2m11s
Trigger cinny-mobile / dispatch (push) Successful in 1s
Apply the auto-fixable lint rules and the formatter, and drop the Vite build artifacts.
2026-11-01 04:23:53 +11:00

18 lines
348 B
TypeScript

import { useEffect, useMemo } from 'react';
export const useObjectURL = (object?: Blob): string | undefined => {
const url = useMemo(() => {
if (object) return URL.createObjectURL(object);
return undefined;
}, [object]);
useEffect(
() => () => {
if (url) URL.revokeObjectURL(url);
},
[url],
);
return url;
};