/
vshmidt
/
label-studio
Обзор
Документация
Войти
/
vshmidt
/
label-studio
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
web/libs/core/src/lib/hooks/useCopyText.tsx
17 строк
555 B
Andrew
fix: BROS-352: Revert order of returned params in `useCopyText()` (#8238)
28 авг 2025, 22:56
Не верифицирован
28 авг 2025, 22:56
c828b85
Код
Авторство
О чём код?
import { useCallback, useState } from "react"; import { copyText, isDefined } from "../utils/helpers"; export const useCopyText = ({ defaultText = "", timeout = 1200 }: { defaultText?: string; timeout?: number } = {}) => { const [copied, setCopied] = useState(false); const copyTextCallback = useCallback( (text?: string) => { setCopied(true); copyText(isDefined(text) ? text : defaultText); setTimeout(() => setCopied(false), timeout); }, [defaultText, timeout], ); return [copyTextCallback, copied] as const; };