Store typedef on the helper and use it to show a parameter list

This commit is contained in:
Olivier Guyot
2019-09-24 09:12:51 +02:00
parent 5ee3063d01
commit 6929cb3001
8 changed files with 70 additions and 11 deletions
+26
View File
@@ -0,0 +1,26 @@
import React, {PureComponent} from 'react';
import {string} from 'prop-types';
import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter';
import {coy} from 'react-syntax-highlighter/dist/styles/prism';
class Code extends PureComponent {
render() {
let language = this.props.language;
if (!language) {
language = 'js';
}
return (
<SyntaxHighlighter language={language} style={coy}>
{this.props.value}
</SyntaxHighlighter>
);
}
}
Code.propTypes = {
value: string.isRequired,
language: string
};
export default Code;