MCPcopy Create free account
hub / github.com/OpenPipe/OpenPipe / useCopyToClipboard

Function useCopyToClipboard

app/src/utils/useCopyToClipboard.ts:3–24  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import { useToast } from "@chakra-ui/react";
2
3export const useCopyToClipboard = () => {
4 const toast = useToast();
5
6 const copyToClipboard = async (text?: string) => {
7 try {
8 await navigator.clipboard.writeText(text as string);
9 toast({
10 title: "Copied to clipboard",
11 status: "success",
12 duration: 2000,
13 });
14 } catch (err) {
15 toast({
16 title: "Failed to copy to clipboard",
17 status: "error",
18 duration: 2000,
19 });
20 }
21 };
22
23 return copyToClipboard;
24};

Callers 4

FormattedJsonFunction · 0.90
CopiableCodeTabsFunction · 0.90
ExtendableAreaFunction · 0.90
NodesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected