Download frontend/src/hooks/useCopyText.js from leowuming/rag: direct link, hf CLI and curl.
- Browser
- Download file 371 Bytes
-
https://huggingface.co/spaces/leowuming/rag/resolve/main/frontend/src/hooks/useCopyText.js
- Command line
-
hf download hf://spaces/leowuming/rag/frontend/src/hooks/useCopyText.js
-
curl -L -o useCopyText.js https://huggingface.co/spaces/leowuming/rag/resolve/main/frontend/src/hooks/useCopyText.js
371 Bytes
| 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 }; | |
| } | |