import React from 'react'; import { Tabs } from 'antd'; const { TabPane } = Tabs; const LANGS = { tsx: 'TypeScript', jsx: 'JavaScript', }; const CodePreview = ({ toReactComponent, codes }) => { const langList = Object.keys(codes).sort().reverse(); let content; if (langList.length === 1) { content = toReactComponent([ 'pre', { lang: langList[0], highlighted: codes[langList[0]], }, ]); } else { content = ( {langList.map(lang => ( {toReactComponent([ 'pre', { lang, highlighted: codes[lang], }, ])} ))} ); } return
{content}
; }; export default CodePreview;