sarink / react-file-drop

React component for Gmail or Facebook -like drag and drop file uploader

Home Page:https://www.sarink.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove file

jbk75 opened this issue · comments

Hi,
how is it possible to remove file that has been dropped in the read-file-drop ?

Hi @jbk75 , can you explain your use case? I'm not sure I understand the problem. Do you possibly want to filter the list of files/could something like this help?

Hi 👋 , I come with the same question, I'm using the field as part of a pseudo form and once I upload the file to S3 I want to be able to clear the input so the user is either able to proceed with the form or drop a new file on the component.

Hi @castrolem , can you explain? FileDrop does not render any input, as you can see from the demo the UI is reset as soon as the user is done dragging over the target

Oh yeah, what I meant was that I was using the Component as part of a form-like behaviour component, but the value of the file was remaining on the Component even after it finished uploading.

So I hooked the callback of the upload event to clear the state of the Component once finished too, but it felt a bit tacky to do it that way, it would have been nicer if the component exposed a clear prop to clear the state.

Hi @jbk75 , can you explain your use case? I'm not sure I understand the problem. Do you possibly want to filter the list of files/could something like this help?

Hi Sarink, Nevermind, I used another approach, thanks

@castrolem I'm still a little lost, what do you mean by the "value of the file"? FileDrop keeps no internal state about the file. Do you have any example code to share? It sounds like you found a straightforward workaround, but if there's an API change that we can make to improve the usability of FileDrop, I'm interested! I just don't completely understand what the suggestion is/what it would be 😅