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

Function useObjectUrl

packages/shared/src/hooks/useObjectUrl.ts:4–21  ·  view source on GitHub ↗
(blob?: Blob)

Source from the content-addressed store, hash-verified

2
3/** A URL that shows the blob, revoked once the blob changes or unmounts. */
4export const useObjectUrl = (blob?: Blob): string | undefined => {
5 const [url, setUrl] = useState<string>();
6
7 useEffect(() => {
8 if (!blob) {
9 setUrl(undefined);
10
11 return undefined;
12 }
13
14 const objectUrl = URL.createObjectURL(blob);
15 setUrl(objectUrl);
16
17 return () => URL.revokeObjectURL(objectUrl);
18 }, [blob]);
19
20 return url;
21};

Callers 2

SlackShareModalFunction · 0.90
SnapshotShareContentFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected