From 4cffd6d7069e1ccbf466b4eba5573c50c2e85725 Mon Sep 17 00:00:00 2001 From: Calli Date: Mon, 3 Jul 2023 21:44:38 +0300 Subject: [PATCH] move file reader initialization to component mount --- src/app/components/Backup/UploadDialog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/Backup/UploadDialog.tsx b/src/app/components/Backup/UploadDialog.tsx index 6b5b55c..5f75800 100644 --- a/src/app/components/Backup/UploadDialog.tsx +++ b/src/app/components/Backup/UploadDialog.tsx @@ -15,7 +15,6 @@ export const UploadDialog = ({ }) => { const [file, setFile] = useState(); - const fileReader = new FileReader(); const { restoreCharacters } = useContext(CharacterContext); const error = new Error("Invalid input"); @@ -33,6 +32,7 @@ export const UploadDialog = ({ return characters; }; useEffect(() => { + const fileReader = new FileReader(); if (file) { fileReader.onload = (event) => { if (!event || event.target === null) return;