From dad69e0d0fea7163385e72868ca16670b50659fd Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 30 Apr 2025 03:11:56 +0200 Subject: [PATCH] Fix Vencord Notifications & ImageZoom causing crashes --- src/plugins/imageZoom/index.tsx | 15 ++++++++++----- src/webpack/common/react.ts | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/plugins/imageZoom/index.tsx b/src/plugins/imageZoom/index.tsx index 25a0ab7d..d7e8d487 100644 --- a/src/plugins/imageZoom/index.tsx +++ b/src/plugins/imageZoom/index.tsx @@ -21,6 +21,7 @@ import { definePluginSettings } from "@api/Settings"; import { makeRange } from "@components/PluginSettings/components"; import { debounce } from "@shared/debounce"; import { Devs } from "@utils/constants"; +import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import { Menu, ReactDOM } from "@webpack/common"; import { JSX } from "react"; @@ -237,12 +238,16 @@ export default definePlugin({ }, renderMagnifier(instance) { - if (instance.props.id === ELEMENT_ID) { - if (!this.currentMagnifierElement) { - this.currentMagnifierElement = ; - this.root = ReactDOM.createRoot(this.element!); - this.root.render(this.currentMagnifierElement); + try { + if (instance.props.id === ELEMENT_ID) { + if (!this.currentMagnifierElement) { + this.currentMagnifierElement = ; + this.root = ReactDOM.createRoot(this.element!); + this.root.render(this.currentMagnifierElement); + } } + } catch (error) { + new Logger("ImageZoom").error("Failed to render magnifier:", error); } }, diff --git a/src/webpack/common/react.ts b/src/webpack/common/react.ts index 99f3f9dd..aa279d65 100644 --- a/src/webpack/common/react.ts +++ b/src/webpack/common/react.ts @@ -28,7 +28,7 @@ export let useRef: typeof React.useRef; export let useReducer: typeof React.useReducer; export let useCallback: typeof React.useCallback; -export const ReactDOM: typeof import("react-dom") & typeof import("react-dom/client") = findByPropsLazy("createPortal", "render"); +export const ReactDOM: typeof import("react-dom") & typeof import("react-dom/client") = findByPropsLazy("createPortal"); waitFor("useState", m => { React = m;