From b87447b543bb833dec6ce9d17b308e73230be136 Mon Sep 17 00:00:00 2001 From: Leangseu Kim Date: Wed, 26 Apr 2023 15:21:03 -0400 Subject: [PATCH] fix: file input handler --- 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 b989d05..e45a5be 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; };