Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: fix react error 409

Abdullah Atta6c122c6498a9
diff --git a/packages/editor/src/components/popup-presenter/index.tsx b/packages/editor/src/components/popup-presenter/index.tsx
index 9bd2de96f..4cb8ecc92 100644
--- a/packages/editor/src/components/popup-presenter/index.tsx
+++ b/packages/editor/src/components/popup-presenter/index.tsx
@@ -24,7 +24,11 @@ import {
PopupPresenterProps,
PopupPresenter
} from "@notesnook/ui";
-import { getPopupRoot, getToolbarElement } from "../../toolbar/utils/dom";
+import {
+ getPopupRoot,
+ getToolbarElement,
+ unmountPopupRoot
+} from "../../toolbar/utils/dom";
import {
useIsMobile,
useToolbarStore
@@ -117,7 +121,7 @@ export function showPopup(options: ShowPopupOptions) {
const { popup, ...props } = options;
function hide() {
- getPopupRoot().unmount();
+ unmountPopupRoot();
}
getPopupRoot().render(
diff --git a/packages/editor/src/toolbar/utils/dom.ts b/packages/editor/src/toolbar/utils/dom.ts
index 2b61192f0..4f35ea375 100644
--- a/packages/editor/src/toolbar/utils/dom.ts
+++ b/packages/editor/src/toolbar/utils/dom.ts
@@ -46,3 +46,8 @@ export function getPopupRoot() {
if (!popupRoot) popupRoot = createRoot(getPopupContainer());
return popupRoot;
}
+
+export function unmountPopupRoot() {
+ if (popupRoot) popupRoot.unmount();
+ popupRoot = undefined;
+}