From 7ac555baa0adec1809a8868dd1005601b877c124 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 26 Nov 2020 16:32:48 +1100 Subject: [PATCH] Fix null reference error when image upload dialog is closed when image upload finishes --- src/modals/SelectMapModal.js | 4 +++- src/modals/SelectTokensModal.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modals/SelectMapModal.js b/src/modals/SelectMapModal.js index 96e7184..d9930f6 100644 --- a/src/modals/SelectMapModal.js +++ b/src/modals/SelectMapModal.js @@ -95,7 +95,9 @@ function SelectMapModal({ await handleImageUpload(file); } // Set file input to null to allow adding the same image 2 times in a row - fileInputRef.current.value = null; + if (fileInputRef.current) { + fileInputRef.current.value = null; + } } async function handleImageUpload(file) { diff --git a/src/modals/SelectTokensModal.js b/src/modals/SelectTokensModal.js index f13c3e5..89ee6ee 100644 --- a/src/modals/SelectTokensModal.js +++ b/src/modals/SelectTokensModal.js @@ -74,7 +74,9 @@ function SelectTokensModal({ isOpen, onRequestClose }) { await handleImageUpload(file); } // Set file input to null to allow adding the same image 2 times in a row - fileInputRef.current.value = null; + if (fileInputRef.current) { + fileInputRef.current.value = null; + } } async function handleImageUpload(file) {