From facf1c88666cb1a9b1c262a859bb57905eb5f40b Mon Sep 17 00:00:00 2001 From: alipov_d Date: Fri, 27 Oct 2023 18:14:39 +0300 Subject: [PATCH] fix: file input handler hasFile run only once, it will always be null --- src/components/GradesView/ImportGradesButton/hooks.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/GradesView/ImportGradesButton/hooks.js b/src/components/GradesView/ImportGradesButton/hooks.js index b989d05e..e45a5be4 100644 --- a/src/components/GradesView/ImportGradesButton/hooks.js +++ b/src/components/GradesView/ImportGradesButton/hooks.js @@ -6,11 +6,10 @@ export const useImportButtonData = () => { const submitImportGradesButtonData = thunkActions.grades.useSubmitImportGradesButtonData(); const fileInputRef = useRef(); - const hasFile = fileInputRef.current && fileInputRef.current.files[0]; - const handleClickImportGrades = () => hasFile && fileInputRef.current.click(); + const handleClickImportGrades = () => fileInputRef.current?.click(); const handleFileInputChange = () => { - if (hasFile) { + if (fileInputRef.current?.files[0]) { const clearInput = () => { fileInputRef.current.value = null; };