From 3be734f6e68ef854eab5361bf05526c0c346446a Mon Sep 17 00:00:00 2001 From: Jeff McMillen Date: Tue, 10 Dec 2024 11:55:39 -0600 Subject: [PATCH] Finally got to filter rejectedFiles correctly --- .../_common/Form/FileInputDropZone.jsx | 39 +++---------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/client/src/components/_common/Form/FileInputDropZone.jsx b/client/src/components/_common/Form/FileInputDropZone.jsx index d69c440dd..27f7946b4 100644 --- a/client/src/components/_common/Form/FileInputDropZone.jsx +++ b/client/src/components/_common/Form/FileInputDropZone.jsx @@ -45,27 +45,11 @@ function FileInputDropZone({ } }; - const handleClick = (index) => { - // rejectedFiles.splice(index, 1); - // setRejectedFiles(rejectedFiles); - // useState(setRejectedFiles(rejectedFiles)); - setRejectedFiles(rejectedFiles.splice(index, 1)); - setRejectedFiles(rejectedFiles); - }; - - // useEffect(() => { - // setRejectedFiles(rejectedFiles); - // console.log('useEffect'); - // }, [rejectedFiles]); - - const refreshRejectedFiles = () => { - setRejectedFiles(rejectedFiles); - } - // useEffect(refreshRejectedFiles, [rejectedFiles]); - - const removeRejectedFile = (index) => { - rejectedFiles.splice(index, 1); - // setRejectedFiles(rejectedFiles); + const removeRejectedFile = (i) => { + const newRejectedFiles = rejectedFiles.filter( + (file) => file !== rejectedFiles[i] + ); + setRejectedFiles(newRejectedFiles); }; const showFileList = (files && files.length > 0) || rejectedFiles.length > 0; @@ -100,18 +84,7 @@ function FileInputDropZone({