12 lines
274 B
TypeScript
12 lines
274 B
TypeScript
import { useMemo } from 'react';
|
|
|
|
/** Return a preview URL for a file. */
|
|
function usePreview(file: File | null | undefined): string | undefined {
|
|
return useMemo(() => {
|
|
if (file) {
|
|
return URL.createObjectURL(file);
|
|
}
|
|
}, [file]);
|
|
}
|
|
|
|
export { usePreview };
|