import clsx from 'clsx'; import CopyButton from 'components/post/CopyButton'; import useCopyToClipboard from 'lib/hooks/useCopyToClipboard'; import { DetailedHTMLProps, HTMLAttributes, memo, useCallback, useRef, } from 'react'; type Props = {} & DetailedHTMLProps< HTMLAttributes, HTMLPreElement >; const Pre = ({ ...rest }: Props) => { const { children, className, ...props } = rest; const preRef = useRef(null); const { copy } = useCopyToClipboard(); const handleCopy = useCallback(() => { if (!preRef.current) throw new Error('Can not access pre element.'); if (preRef.current.textContent == null) return; copy(preRef.current.textContent); }, [copy]); return ( <>
        {children}
        
      
); }; export default memo(Pre);