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;