import { ReactComponentElement, useEffect, useState } from 'react'; // @ts-ignore import { CopyToClipboard } from 'react-copy-to-clipboard'; import SyntaxHighlighter from 'react-syntax-highlighter'; /* eslint-disable-next-line */ export interface InlineCommandProps { language: string; command: string; callback?: (command: string) => void; } export function InlineCommand({ language, command, callback, }: InlineCommandProps): ReactComponentElement { const [copied, setCopied] = useState(false); useEffect(() => { let t: NodeJS.Timeout; if (copied) { t = setTimeout(() => { setCopied(false); }, 3000); } return () => { t && clearTimeout(t); }; }, [copied]); return (
{ setCopied(true); if (typeof callback === 'function') callback(command); }} >
); } export default InlineCommand;