Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with initial files #217

Open
mortezakarimi opened this issue Jul 3, 2024 · 0 comments
Open

issue with initial files #217

mortezakarimi opened this issue Jul 3, 2024 · 0 comments

Comments

@mortezakarimi
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-dropzone-uploader@2.11.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-dropzone-uploader/dist/Dropzone.tsx b/node_modules/react-dropzone-uploader/dist/Dropzone.tsx
index da29a80..d9cc8b8 100644
--- a/node_modules/react-dropzone-uploader/dist/Dropzone.tsx
+++ b/node_modules/react-dropzone-uploader/dist/Dropzone.tsx
@@ -210,7 +210,7 @@ export interface IDropzoneProps {
   autoUpload: boolean
   timeout?: number
 
-  initialFiles?: File[]
+  initialFiles?: IFileWithMeta[]
 
   /* component customization */
   disabled: boolean | CustomizationFunction<boolean>
@@ -255,12 +255,12 @@ class Dropzone extends React.Component<IDropzoneProps, { active: boolean; dragge
   }
 
   componentDidMount() {
-    if (this.props.initialFiles) this.handleFiles(this.props.initialFiles)
+    if (this.props.initialFiles) this.files = this.props.initialFiles
   }
 
   componentDidUpdate(prevProps: IDropzoneProps) {
     const { initialFiles } = this.props
-    if (prevProps.initialFiles !== initialFiles && initialFiles) this.handleFiles(initialFiles)
+    if (prevProps.initialFiles !== initialFiles && initialFiles) this.files = initialFiles
   }
 
   componentWillUnmount() {
@@ -488,7 +488,7 @@ class Dropzone extends React.Component<IDropzoneProps, { active: boolean; dragge
         fileWithMeta.meta.videoHeight = video.videoHeight
       }
       if (!isImage) URL.revokeObjectURL(objectUrl)
-    } catch (e) {
+    } catch (e:any) {
       URL.revokeObjectURL(objectUrl)
     }
     this.forceUpdate()
@@ -500,7 +500,7 @@ class Dropzone extends React.Component<IDropzoneProps, { active: boolean; dragge
     let params: IUploadParams | null = null
     try {
       params = await getUploadParams(fileWithMeta)
-    } catch (e) {
+    } catch (e:any) {
       console.error('Error Upload Params', e.stack)
     }
     if (params === null) return
@@ -630,7 +630,7 @@ class Dropzone extends React.Component<IDropzoneProps, { active: boolean; dragge
     const SubmitButton = SubmitButtonComponent || SubmitButtonDefault
     const Layout = LayoutComponent || LayoutDefault
 
-    let previews = null
+    let previews:any = null
     if (PreviewComponent !== null) {
       previews = files.map(f => {
         return (
diff --git a/node_modules/react-dropzone-uploader/dist/utils.ts b/node_modules/react-dropzone-uploader/dist/utils.ts
index 707918d..dcb10b9 100644
--- a/node_modules/react-dropzone-uploader/dist/utils.ts
+++ b/node_modules/react-dropzone-uploader/dist/utils.ts
@@ -94,7 +94,7 @@ export const mergeStyles = (
 export const getFilesFromEvent = (
   event: React.DragEvent<HTMLElement> | React.ChangeEvent<HTMLInputElement>,
 ): Array<File | DataTransferItem> => {
-  let items = null
+  let items:any = null
 
   if ('dataTransfer' in event) {
     const dt = event.dataTransfer

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant