File size: 371 Bytes
f8b5d42 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import { useState } from "react";
export default function useCopyText(delay = 2500) {
const [copied, setCopied] = useState(false);
const copyText = async (content) => {
if (!content) return;
navigator?.clipboard?.writeText(content);
setCopied(content);
setTimeout(() => {
setCopied(false);
}, delay);
};
return { copyText, copied };
}
|