From 0045f9136b4ae47e6eaa83f9dc8d6f62118478ac Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Fri, 8 Oct 2021 18:26:38 +0300 Subject: [PATCH] refactor(highlight-code): add UNSAFE prefix for lifecycle methods Refs #7497 --- src/core/components/highlight-code.jsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/components/highlight-code.jsx b/src/core/components/highlight-code.jsx index 982179944e7..f85694086dc 100644 --- a/src/core/components/highlight-code.jsx +++ b/src/core/components/highlight-code.jsx @@ -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 () {