Skip to content

Commit

Permalink
fix: file input handler
Browse files Browse the repository at this point in the history
hasFile run only once, it will always be null
  • Loading branch information
DmytroAlipov committed Oct 27, 2023
1 parent 3644172 commit facf1c8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/components/GradesView/ImportGradesButton/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit facf1c8

Please sign in to comment.