This commit is contained in:
Arjun Patel
2026-06-01 17:08:25 -07:00
parent 78456a4b1d
commit d9c2a1ed1b
8 changed files with 22 additions and 21 deletions
+1 -6
View File
@@ -3,11 +3,6 @@ import { useEffect, useState } from 'react';
/**
* Creates an object URL for a Blob/File and revokes it when the source changes
* or the component unmounts. Returns null when given null.
*
* `createObjectURL` is an imperative side effect that must run inside an effect,
* so publishing the resulting URL to state here is genuine external-resource
* synchronization rather than a render cascade — hence the single, contained
* lint suppression below.
*/
export function useObjectUrl(source: Blob | null): string | null {
const [url, setUrl] = useState<string | null>(null);
@@ -15,7 +10,7 @@ export function useObjectUrl(source: Blob | null): string | null {
useEffect(() => {
if (!source) return;
const objectUrl = URL.createObjectURL(source);
// Intended external-resource publish (see hook doc), not a render cascade.
// Intended external-resource publish to sync, not a render cascade.
// eslint-disable-next-line react-hooks/set-state-in-effect
setUrl(objectUrl);
return () => {