pass rejection reason to onDropRejected callback
See original GitHub issueDo you want to request a feature or report a bug?
- I found a bug
- I want to propose a feature
I’d like to get a reason for rejection in the onDropRejected
callback
currently I only get the file that was rejected.
There was a request opened up previously #735, but it was closed. I am not sure why because the request was valid one and the response didn’t really help the reporter.
From what I can see there can be 3 reasons:
- you dragged multiple files to
multiple={false}
dropzone - bad mime type
- file too big
Sure I can have a series of if statements in my callback to recognize what was the reason for rejection, but why do this work again when react-dropzone already done it?
Also it would be nice to have default error messages for those 3 scenarios, I’d propose:
File ${file.name} is not supported
Only accepts a single file
File ${file.name} is ${bytes(file.size)}, the upper limit for file size is ${bytes(maxFileSize)}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:20 (1 by maintainers)
Top Results From Across the Web
Dropzone - Procore
onDropRejected, function, false. Callback for when the drop event occurs. Note that if no files are rejected, this callback is not invoked.
Read more >react-dropzone
Note that the onDrop callback will always be invoked regardless if the dropped files were accepted or rejected. If you'd like to react...
Read more >react-dropzone - accessing files added by click not drop
The above code handles both drag and drop, however it only gives you the latest added files and not the entire list of...
Read more >10 React-Dropzone Best Practices - CLIMB
To add validation logic to React-Dropzone, you can use the onDropAccepted and onDropRejected props. These props allow you to specify a callback ......
Read more >5 reasons why you get reject from Thailand Pass - YouTube
5 reasons why you get reject from Thailand Pass... Appreciated in my information and want to buy me a coffee (Donate...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for looking into it @rolandjitsu
Any implementation for this will be step forward in my opinion - but I have one suggestion - maybe it would be better to keep the error/validation as a string code that can be easily compared by a developer if he wants to show their own error messages?
I mean something like I’ve previously suggested:
file-invalid-type
,file-too-large
,file-too-small
,file-overflow
/file-excessive
, etc.Or maybe even combined approach? Like this:
HEllo. Any news about PR?