import { useEvent } from '@/hooks/useEvent'; import React, { useState } from 'react'; import { Button } from './ui/button'; import { LuCopy, LuCopyCheck } from 'react-icons/lu'; import { toast } from 'sonner'; import { useTranslation } from '@i18next-toolkit/react'; export const CodeBlock: React.FC<{ code: string; }> = React.memo((props) => { const [copied, setCopied] = useState(false); const { t } = useTranslation(); const handleCopy = useEvent(() => { window.navigator.clipboard.writeText(props.code); toast(t('Copied into clipboard!')); setCopied(true); }); return (
{props.code}