20 строки
690 B
TypeScript
20 строки
690 B
TypeScript
import * as React from 'react';
|
|
import Highlight, { defaultProps } from 'prism-react-renderer';
|
|
import theme from 'prism-react-renderer/themes/duotoneLight';
|
|
|
|
export const Highlighted: React.FC<{ code: string }> = props => (
|
|
<Highlight {...defaultProps} code={props.code} language="jsx" theme={theme}>
|
|
{({ className, style, tokens, getLineProps, getTokenProps }) => (
|
|
<pre className={className} style={style}>
|
|
{tokens.map((line, i) => (
|
|
<div {...getLineProps({ line, key: i })}>
|
|
{line.map((token, key) => (
|
|
<span {...getTokenProps({ token, key })} />
|
|
))}
|
|
</div>
|
|
))}
|
|
</pre>
|
|
)}
|
|
</Highlight>
|
|
);
|