Skip to content

Commit dc43ba8

Browse files
♻️ error handling
1 parent e2badf8 commit dc43ba8

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const Example = () => {
4545
data={{
4646
text: "Like humans, flamingos make friends for life",
4747
url: "https://bit.ly/2UWTnlL",
48-
title: "Share this article on Flamingos",
48+
title: "Flamingos",
4949
}}
5050
>
5151
<button>Share 🔗</button>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-web-share",
33
"author": "Harsh Zalavadiya",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"license": "MIT",
66
"repository": "harshzalavadiya/react-web-share",
77
"module": "dist/react-web-share.esm.js",

src/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ export const RWebShare = ({ children, data, sites = Object.keys(iconList) }: RWe
1717
};
1818

1919
const handleOnClick = () => {
20-
if ((window as any).navigator.share) {
21-
(window as any).navigator.share(shareData);
22-
} else {
23-
onOpen();
20+
try {
21+
if ((window as any).navigator.share) {
22+
(window as any).navigator.share(shareData);
23+
} else {
24+
onOpen();
25+
}
26+
} catch (e) {
27+
console.error(e);
2428
}
2529
};
2630

stories/Thing.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const Default = () => (
1313
data={{
1414
text: "Like humans, flamingos make friends for life",
1515
url: "https://bit.ly/2UWTnlL",
16-
title: "Share this article on Flamingos",
16+
title: "Flamingos",
1717
}}
1818
>
1919
<button>Share 🔗</button>

0 commit comments

Comments
 (0)