Skip to content

Commit

Permalink
fix: 컴포넌트 언마운트 시 프리뷰 이미지 revoke
Browse files Browse the repository at this point in the history
  • Loading branch information
ojm51 committed Aug 26, 2024
1 parent 319f21c commit dfc0519
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion components/Inputs/FileInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react";
import { useEffect, useState } from "react";

import Image from "next/image";
import plusIcon from "@/assets/images/ic_plus.png";
Expand Down Expand Up @@ -26,6 +26,14 @@ function FileInput({ name, label, onChange }: FileInputProps) {
setPreview("");
};

useEffect(() => {
return () => {
if (preview) {
URL.revokeObjectURL(preview);
}
};
}, [preview]);

return (
<div className="file-input-wrapper">
<div className="mb-3 text-lg font-bold text-gray-800">{label}</div>
Expand Down

0 comments on commit dfc0519

Please sign in to comment.