2021-12-13 12:54:54 +00:00
|
|
|
import { useEffect } from "react";
|
|
|
|
|
2021-12-12 16:50:58 +00:00
|
|
|
interface ImagePreviewProps {
|
2021-12-13 12:54:54 +00:00
|
|
|
imageData: Blob;
|
2021-12-12 16:50:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function ImagePreview({ imageData }: ImagePreviewProps) {
|
2021-12-13 12:54:54 +00:00
|
|
|
const imageUrl = URL.createObjectURL(imageData);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
return () => {
|
|
|
|
URL.revokeObjectURL(imageUrl);
|
|
|
|
}
|
|
|
|
}, [imageUrl]);
|
2021-12-12 16:50:58 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="blur-sm mx-auto">
|
|
|
|
<img
|
|
|
|
alt="preview"
|
|
|
|
src={imageUrl}
|
|
|
|
className="object-contain max-h-96 max-w-96 mx-auto"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ImagePreview;
|