blob: 65c4cb9f7dfe69a2bc83f3c27811daad7f18f53d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import React, {useState} from 'react';
import copy from 'clipboard-copy';
function CopyButton(props) {
const [copied, setCopied] = useState(false);
const handleClick = async () => {
await copy("https://sho.rest/" + props.hash);
setCopied(true);
};
let content;
if (copied) {
content = <span>Link Copied!</span>;
} else {
content = <strong>Copy Link</strong>;
}
return (
<span className="copy-text right-item" onClick={handleClick}>{content}</span>
)
}
export default CopyButton;
|