MCPcopy
hub / github.com/megh-bari/pattern-craft / copyToClipboard

Function copyToClipboard

src/hooks/useCopy.tsx:9–19  ·  view source on GitHub ↗
(code: string, id: string)

Source from the content-addressed store, hash-verified

7 const [copiedId, setCopiedId] = useState<string | null>(null);
8
9 const copyToClipboard = async (code: string, id: string) => {
10 try {
11 await navigator.clipboard.writeText(code);
12 setCopiedId(id);
13 toast.success("Code copied to clipboard!");
14 setTimeout(() => setCopiedId(null), 1000);
15 } catch (error) {
16 console.error("Failed to copy to clipboard:", error);
17 toast.error("Failed to copy code");
18 }
19 };
20
21 const isCopied = (id: string) => copiedId === id;
22

Callers 1

PatternCardFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected