Skip to content

Commit 97e8e37

Browse files
committed
Added ID parameter to CodeSyntax
Tested with ReactDOM node querySelector
1 parent ff99092 commit 97e8e37

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

components/CodeSyntax.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const copyToClipboard = str => {
4444
}
4545

4646

47-
const CodeSyntax = ({ children, highlightedLines, language, showLineNumbers }) => {
47+
const CodeSyntax = ({ id, children, highlightedLines, language, showLineNumbers }) => {
4848

4949
const copyCodeToClipboard = () => {
5050
copyToClipboard(children)
@@ -56,7 +56,7 @@ const CodeSyntax = ({ children, highlightedLines, language, showLineNumbers }) =
5656
newHighlightedLines[lineNumber] = 1
5757
})
5858
return (
59-
<div>
59+
<div id={id}>
6060
<SyntaxHighlighter
6161
style={githubGist}
6262
language={language || 'javascript'}
@@ -74,6 +74,7 @@ const CodeSyntax = ({ children, highlightedLines, language, showLineNumbers }) =
7474
}
7575

7676
CodeSyntax.propTypes = {
77+
id: PropTypes.string.isRequired,
7778
children: PropTypes.any.isRequired,
7879
highlightedLines: PropTypes.array,
7980
language: PropTypes.string,

0 commit comments

Comments
 (0)