Spaces:
Configuration error
Configuration error
Download web/apps/labelstudio/src/hooks/useCopyText.ts from bisalsaha/lebel-studio: direct link, hf CLI and curl.
- Browser
- Download file 489 Bytes
-
https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/apps/labelstudio/src/hooks/useCopyText.ts
- Command line
-
hf download hf://spaces/bisalsaha/lebel-studio/web/apps/labelstudio/src/hooks/useCopyText.ts
-
curl -L -o useCopyText.ts https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/apps/labelstudio/src/hooks/useCopyText.ts
489 Bytes
| import { useCallback, useState } from "react"; | |
| import { copyText, isDefined } from "../utils/helpers"; | |
| export const useCopyText = ({ defaultText = "", timeout = 1200 }) => { | |
| const [copied, setCopied] = useState(false); | |
| const copyTextCallback = useCallback( | |
| (text?) => { | |
| setCopied(true); | |
| copyText(isDefined(text) ? text : defaultText); | |
| setTimeout(() => setCopied(false), timeout); | |
| }, | |
| [defaultText, timeout], | |
| ); | |
| return [copied, copyTextCallback]; | |
| }; | |