odysseyscience / react-s3-uploader

React component that renders an <input type="file"/> and automatically uploads to an S3 bucket

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why the callback signature is callback(data)?

ashoksahoo opened this issue · comments

client.get('/my/signing/server', { params })
  .then(data => {
    callback(data);
  })

Signature for callback is usually callback(err, data)
Why there is an antipattern here?

Good question (not sure if this was merged from a PR or not, but should have been criticized regardless).

But the library doesn't necessarily know what to do with your error, so maybe its okay as is. Possibly the name callback is where the confusion lies, since that implies the convention you mention. If instead, it were named, continueWithSignedData, then maybe it would feel better.

I guess we could just forward the error on to onError if it was passed back. Feel free to submit a PR if you like, just check fn.arity for backward compatibility. Will close for now, as the question has been answered, but feel free to re-open if necessary.