From e58b453f24c8b4081361112862d29c34eb22009d Mon Sep 17 00:00:00 2001 From: Melonai Date: Wed, 20 May 2020 19:52:18 +0200 Subject: port to react and better error handling in backend --- client/src/Components/CopyButton.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 client/src/Components/CopyButton.js (limited to 'client/src/Components/CopyButton.js') diff --git a/client/src/Components/CopyButton.js b/client/src/Components/CopyButton.js new file mode 100644 index 0000000..0ae8e83 --- /dev/null +++ b/client/src/Components/CopyButton.js @@ -0,0 +1,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 = Link Copied!; + } else { + content = Copy Link; + } + + return ( + {content} + ) +} + +export default CopyButton; \ No newline at end of file -- cgit 1.4.1