From dcad33f0c5de96a6493413eb753b738aec03be9e Mon Sep 17 00:00:00 2001 From: Callum Fairbairn <86301717+callum-fairbairn-cazoo@users.noreply.github.com> Date: Wed, 27 Jul 2022 10:43:26 +0100 Subject: [PATCH] Don't change progress bar status if noProgressBar is true --- src/useCSVReader.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/useCSVReader.tsx b/src/useCSVReader.tsx index 387db2d..24cda31 100644 --- a/src/useCSVReader.tsx +++ b/src/useCSVReader.tsx @@ -39,6 +39,7 @@ export interface Props { noDrag?: boolean; noDragEventsBubbling?: boolean; noKeyboard?: boolean; + noProgressBar?: boolean; multiple?: boolean; required?: boolean; preventDropOnDocument?: boolean; @@ -72,6 +73,7 @@ function useCSVReaderComponent() { noDrag = false, noDragEventsBubbling = false, noKeyboard = false, + noProgressBar = false, multiple = false, required = false, preventDropOnDocument = true, @@ -282,7 +284,9 @@ function useCSVReaderComponent() { type: 'setFiles', }); - setDisplayProgressBar('block'); + if (!noProgressBar) { + setDisplayProgressBar('block'); + } // if (onDrop) { // onDrop(acceptedFiles, fileRejections, event) @@ -352,9 +356,11 @@ function useCSVReaderComponent() { PapaParse.parse(e.target.result, configs); }; reader.onloadend = () => { - setTimeout(() => { - setDisplayProgressBar('none'); - }, 2000); + if (!noProgressBar) { + setTimeout(() => { + setDisplayProgressBar('none'); + }, 2000); + } }; reader.readAsText(file, config.encoding || 'utf-8'); });