Skip to content

Commit

Permalink
Add try catch to copy to cliboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimi Mikadze committed Nov 14, 2019
1 parent bba1f97 commit f95f063
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions frontend/src/components/PostCard/PostCardOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ const PostCardOption = ({ postId, author, closeOption, deletePost }) => {
const [{ auth }] = useStore();

const copyToClipboard = () => {
navigator.clipboard.writeText(
`${process.env.REACT_APP_FRONTEND_URL}${generatePath(Routes.POST, {
id: postId,
})}`
);
try {
navigator.clipboard.writeText(
`${process.env.REACT_APP_FRONTEND_URL}${generatePath(Routes.POST, {
id: postId,
})}`
);
} catch (error) {
console.error('Failed to read clipboard contents: ', error);
}

closeOption();
};

Expand Down

0 comments on commit f95f063

Please sign in to comment.