react-component / react-component/upload

Omit console log on undefined before upload rejections

Open
#251 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
804
Forks
323
Avg merge
12m
Merged PRs (30d)
1

Description

When beforeUpload function returns a rejected promise without a value (signifying do not upload) a undefined is logged to the console. It's merely a bit of annoyance, but I don't see the value added by logging undefined. I believe the below patch would fix this by ignoring undefined rejections

diff --git a/src/AjaxUploader.jsx b/src/AjaxUploader.jsx
index 638c90f..849d051 100644
--- a/src/AjaxUploader.jsx
+++ b/src/AjaxUploader.jsx
@@ -113,7 +113,7 @@ class AjaxUploader extends Component {
         }
         return this.post(file);
       }).catch(e => {
-        console && console.log(e); // eslint-disable-line
+        console && e !== undefined && console.log(e); // eslint-disable-line
       });
     } else if (before !== false) {
       setTimeout(() => this.post(file), 0);

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the catch branch in src/AjaxUploader.jsx, where beforeUpload rejection values are logged. Confirm the behavior for a rejected promise with no value and verify that the console remains quiet in that case while other rejection values are still logged.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.