React-native-share: onClose - Possible Unhandled Promise Rejection

Created on 1 Aug 2016  路  4Comments  路  Source: react-native-share/react-native-share

2016-08-01 11:09:59.584 [warn][tid:com.facebook.react.JavaScript] Possible Unhandled Promise Rejection (id: 3):

getting this error on pressing close running the example

Most helpful comment

@andyfenelon, @IsTheJack, Actually, this is solved by just adding in a catch. If a user doesn't share, it throws an error of Object {error: "User did not share"} 鈥斅爓hich will be unhandled without a catch.

So to prevent the warning you can do:

Share.open({
  // share config here
})
.catch(err => console.log(err));

All 4 comments

I was getting this error too:
simulator screen shot aug 1 2016 2 35 32 pm

I'm getting this also.

@andyfenelon, @IsTheJack, Actually, this is solved by just adding in a catch. If a user doesn't share, it throws an error of Object {error: "User did not share"} 鈥斅爓hich will be unhandled without a catch.

So to prevent the warning you can do:

Share.open({
  // share config here
})
.catch(err => console.log(err));

I don't really like this workaround. IMO the module shouldn't reject the promise in this case because it's not an "error scenario". Can anybody reopen the issue ?

At least, the rejected value must allow distinction between this case and real errors (creating a UserCancelError should do the job).

According to the JS coding conventions, a promise should reject a instance of Error (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject#Description), not an object containing a key named error

I'd remove the use of Exception that is not standard in JavaScript: https://github.com/EstebanFuentealba/react-native-share/blob/master/index.js#L71 (or maybe it's a Windows thing ?)

Are you guys open to a PR ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

saifkamaal picture saifkamaal  路  3Comments

naveedmastan picture naveedmastan  路  3Comments

fredrik-jarnbrost picture fredrik-jarnbrost  路  3Comments

MbF-Sathya picture MbF-Sathya  路  4Comments

kunalnagar picture kunalnagar  路  3Comments