How to reset a dropzone to have no files? #1160
-
I have a dropzone working well. Thanks! But once I process the files with (with my external code), it's not obvious how to remove the I have looked through the docs and code, and don't see anything. I've tried going after |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Simply stop using Create your own file array with useState: const [files, setFiles] = useState<File[]>([]); Then write your onDrop callback (which gives you the File[] as the first agument) in such way that it will copy the files to your state: onDrop: (newFiles: File[]) => {
setFiles([ ...files, ...newFiles ]);
} Of course you are encouraged to write your other callbacks as well (e.g., |
Beta Was this translation helpful? Give feedback.
Simply stop using
acceptedFiles
🙂Create your own file array with useState:
Then write your onDrop callback (which gives you the File[] as the first agument) in such way that it will copy the files to your state:
Of course you are encouraged to write your other callbacks as well (e.g.,
onFileDialogCancel: () => setFiles([])
, etc) to handle your use case accordingly.