'use client'; import clsx from 'clsx'; import CopyButton from 'components/post/copy-button'; import useCopyToClipboard from 'lib/hooks/use-copy-to-clipboard'; import { useCallback, useRef } from 'react'; const CopyCode = () => { const btnRef = useRef(null); const { copy } = useCopyToClipboard(); const handleCopy = useCallback(() => { if (!btnRef.current?.parentElement) throw new Error('Can not access pre element.'); if (btnRef.current.parentElement.textContent == null) return; copy(btnRef.current.parentElement.textContent); }, [copy]); return ( <> ); }; export default CopyCode;