Skip to content

Commit

Permalink
refactor(highlight-code): add UNSAFE prefix for lifecycle methods
Browse files Browse the repository at this point in the history
Refs #7497
  • Loading branch information
char0n committed Nov 2, 2021
1 parent 3cfd350 commit 0045f91
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/core/components/highlight-code.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ export default class HighlightCode extends Component {
}
}

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

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

render () {
Expand Down

0 comments on commit 0045f91

Please sign in to comment.