import { useState } from 'react' import { Light as SyntaxHighlighter } from 'react-syntax-highlighter' import js from 'react-syntax-highlighter/dist/cjs/languages/hljs/javascript' import CopyToClipboard from 'react-copy-to-clipboard' import { examples } from 'data/CodeExamples' import monokaiCustomTheme from 'data/CodeEditorTheme' SyntaxHighlighter.registerLanguage('javascript', js) const ClipboardIcon = () => ( ) const CopiedIcon = () => ( ) const CodeExamples = () => { const [example, setExample] = useState('createUserExample') const [copied, setCopied] = useState(false) const exampleList = [ 'createUserExample', 'subscribeExample', 'readExample', 'createExample', 'updateExample', ] const lang = 'javascript' function handleClick(key: string) { setExample(key) setCopied(false) } const buttons = exampleList.map((id) => { return ( ) }) return (
{buttons}

{ // @ts-ignore examples[example].description }

setCopied(true)} >
{ // @ts-ignore examples[example].code[lang] }
{buttons}
) } export default CodeExamples