()
| 31 | function useCopy(text: string) { |
| 32 | const [copied, setCopied] = useState(false) |
| 33 | const copy = async () => { |
| 34 | try { |
| 35 | await navigator.clipboard.writeText(text) |
| 36 | } catch { |
| 37 | const el = document.createElement('textarea') |
| 38 | el.value = text |
| 39 | document.body.appendChild(el) |
| 40 | el.select() |
| 41 | document.execCommand('copy') |
| 42 | document.body.removeChild(el) |
| 43 | } |
| 44 | setCopied(true) |
| 45 | setTimeout(() => setCopied(false), 2000) |
| 46 | } |
| 47 | return { copied, copy } |
| 48 | } |
| 49 |
nothing calls this directly
no outgoing calls
no test coverage detected