mirror of
https://github.com/nyakang/nyaterm.git
synced 2026-10-30 16:08:28 +00:00
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:
@@ -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(() => {});
|
||||
|
||||
Reference in New Issue
Block a user