bigbuffet-rw/app/soapbox/hooks/forms/usePreview.ts

12 lines
273 B
TypeScript
Raw Normal View History

2023-03-29 18:14:41 -07:00
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 };