bigbuffet-rw/app/soapbox/hooks/forms/usePreview.ts
2023-03-29 20:14:41 -05:00

12 lines
No EOL
273 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 };