Skip to content

Commit

Permalink
refactor(highlight-code): declare properties explicitly
Browse files Browse the repository at this point in the history
Refs #7497
  • Loading branch information
char0n committed Oct 5, 2021
1 parent 24aaa53 commit b7b79bb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/core/components/highlight-code.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export default class HighlightCode extends Component {
canCopy: PropTypes.bool
}

#syntaxHighlighter;
#pre;

downloadText = () => {
saveAs(this.props.value, this.props.fileName || "response.txt")
}
Expand All @@ -40,12 +43,12 @@ export default class HighlightCode extends Component {
}

componentDidMount() {
[this.syntaxHighlighter, this.pre]
[this.#syntaxHighlighter, this.#pre]
.map(element => element?.addEventListener("mousewheel", this.preventYScrollingBeyondElement, { passive: false }))
}

componentWillUnmount() {
[this.syntaxHighlighter, this.pre]
[this.#syntaxHighlighter, this.#pre]
.map(element => element?.removeEventListener("mousewheel", this.preventYScrollingBeyondElement))
}

Expand All @@ -58,14 +61,14 @@ export default class HighlightCode extends Component {

const codeBlock = get(config, "syntaxHighlight.activated")
? <SyntaxHighlighter
ref={elem => this.syntaxHighlighter = elem}
ref={elem => this.#syntaxHighlighter = elem}
language={language}
className={className + " microlight"}
style={getStyle(get(config, "syntaxHighlight.theme"))}
>
{value}
</SyntaxHighlighter>
: <pre ref={elem => this.pre = elem} className={className + " microlight"}>{value}</pre>
: <pre ref={elem => this.#pre = elem} className={className + " microlight"}>{value}</pre>

return (
<div className="highlight-code">
Expand Down

0 comments on commit b7b79bb

Please sign in to comment.