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

Remove all files from dropzone #3

Open
Chingis007 opened this issue Feb 11, 2025 · 1 comment
Open

Remove all files from dropzone #3

Chingis007 opened this issue Feb 11, 2025 · 1 comment

Comments

@Chingis007
Copy link

Hi. I would like to remove all files from dropzone after i send form data, but can`t find function to do so. I hope there is some solution.

@jslno
Copy link

jslno commented Feb 11, 2025

Hey, I also faced this,
Here's how I solved it:

  1. Add this inside the useDropzone function
const reset = useCallback(async () => {
    for (const fileStatus of fileStatuses) {
        await onRemoveFile(fileStatus.id)
    }
}, [fileStatuses, onRemoveFile])
  1. Add the function to the return.
return {
    //... other properties
   reset
}
  1. Add initial state to DropZoneContext
reset: async () => {}
  1. Add the type to UseDropzoneReturn
reset: () => Promise<void>
  1. Now you can call the function (e.g. await dropzone.reset())

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

2 participants