MCPcopy Index your code
hub / github.com/StaticMania/keep-react / useCopy

Function useCopy

hooks/useCopy.tsx:3–25  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import { useState } from 'react'
2
3const useCopy = () => {
4 const [copy, setCopy] = useState<boolean>(false)
5 if (copy) {
6 setTimeout(() => {
7 setCopy(false)
8 }, 3000)
9 }
10 const copyToClipboard = (text: string) => {
11 navigator?.clipboard
12 ?.writeText(text)
13 .then(() => {
14 setCopy(true)
15 })
16 .catch((error) => {
17 console.error(error)
18 setCopy(false)
19 })
20 }
21 return {
22 copy,
23 copyToClipboard,
24 }
25}
26
27export default useCopy

Callers 4

HeroFunction · 0.85
CodeHighlightFunction · 0.85
CodeBoxFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected