better-chatbot / src /hooks /use-copy.ts
Bot
Initial commit for HF Spaces
05c5ed5
Raw
History Blame Contribute Delete
340 Bytes
"use client";
import { useState } from "react";
export const useCopy = (timeout = 2000) => {
const [copied, setCopied] = useState(false);
const copy = (text: string) => {
navigator.clipboard.writeText(text);
setCopied(true);
setTimeout(() => {
setCopied(false);
}, timeout);
};
return { copied, copy };
};