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);
|
|
|
|
|
2021-12-13 22:15:11 +00:00
|
|
|
useEffect(() => {
|
|
|
|
return () => {
|
2021-12-13 12:54:54 +00:00
|
|
|
URL.revokeObjectURL(imageUrl);
|
2021-12-13 22:15:11 +00:00
|
|
|
};
|
2021-12-13 12:54:54 +00:00
|
|
|
}, [imageUrl]);
|
2021-12-12 16:50:58 +00:00
|
|
|
|
|
|
|
return (
|
2021-12-13 22:15:11 +00:00
|
|
|
<div className="blur-sm max-w-4xl mx-auto">
|
2021-12-12 16:50:58 +00:00
|
|
|
<img
|
|
|
|
alt="preview"
|
|
|
|
src={imageUrl}
|
2021-12-13 22:15:11 +00:00
|
|
|
className="object-cover min-w-[70%] my-4 px-2 mx-auto"
|
2021-12-12 16:50:58 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ImagePreview;
|