MCPcopy Create free account
hub / github.com/dailydotdev/apps / useCopyText

Function useCopyText

packages/shared/src/hooks/useCopy.ts:69–87  ·  view source on GitHub ↗
(text?: string)

Source from the content-addressed store, hash-verified

67}
68
69export function useCopyText(text?: string): [boolean, CopyNotifyFunction] {
70 const [copying, setCopying] = useState(false);
71 const { displayToast } = useToastNotification();
72
73 const copy: CopyNotifyFunction = async (props = {}) => {
74 await navigator.clipboard.writeText(props.textToCopy || text);
75
76 if (!props.disableToast) {
77 displayToast(props.message || defaultMessage, props);
78 }
79
80 setCopying(true);
81 setTimeout(() => {
82 setCopying(false);
83 }, 1000);
84 };
85
86 return [copying, copy];
87}

Callers 2

RenderMarkdownFunction · 0.90
HowItWorksSectionFunction · 0.90

Calls 1

useToastNotificationFunction · 0.90

Tested by

no test coverage detected