import React, { useRef, useState } from "react"; export default ({ text }) => { const textareaRef = useRef(null); const [hovered, setHovered] = useState(false); const [copied, setCopied] = useState(false); const copyText = () => { textareaRef.current.select(); document.execCommand("copy"); setCopied(true); }; return (
setHovered(true)} onMouseOut={() => {setHovered(false); setCopied(false)}} > {text} {copied ? "Copied!" : "Click to Copy"}