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; };