fix: Initialize timerRef in CopyButton component to avoid potential undefined behavior

This commit updates the CopyButton component by initializing the timerRef with `undefined` to ensure proper type handling. This change enhances the reliability of the component's functionality when managing clipboard operations.
This commit is contained in:
Kang
2026-05-10 20:00:17 +08:00
parent 2022406bf8
commit 63eebb1352
@@ -10,7 +10,7 @@ interface CopyButtonProps {
export function CopyButton({ value }: CopyButtonProps) {
const { t } = useTranslation();
const [copied, setCopied] = useState(false);
const timerRef = useRef<ReturnType<typeof setTimeout>>();
const timerRef = useRef<ReturnType<typeof setTimeout>>(undefined);
const handleCopy = () => {
navigator.clipboard.writeText(value).catch(() => {});