PaletteSwitcher/client/src/ImagePreview.tsx

28 lines
535 B
TypeScript
Raw Normal View History

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