Skip to content

Commit d35d6f9

Browse files
committed
refactor(highlight-code): add UNSAFE prefix for lifecycle methods
Refs #7497
1 parent 33975d4 commit d35d6f9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/core/components/highlight-code.jsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ export default class HighlightCode extends Component {
5151
}
5252
}
5353

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

58-
componentWillUnmount() {
59-
this.#childNodes?.forEach(node => node.removeEventListener("mousewheel", this.preventYScrollingBeyondElement))
59+
UNSAFE_componentWillUnmount() {
60+
[this.#syntaxHighlighter, this.#pre]
61+
.map(element => element?.removeEventListener("mousewheel", this.preventYScrollingBeyondElement))
6062
}
6163

6264
render () {

0 commit comments

Comments
 (0)