From ffe0ef6dc532f5bf0226e074f95a351b36c5abbd Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Thu, 21 Sep 2023 17:45:06 +0800
Subject: ...

---
 FrontEnd/src/components/InPortal.tsx | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 FrontEnd/src/components/InPortal.tsx

(limited to 'FrontEnd/src/components/InPortal.tsx')

diff --git a/FrontEnd/src/components/InPortal.tsx b/FrontEnd/src/components/InPortal.tsx
new file mode 100644
index 00000000..7cb57ea8
--- /dev/null
+++ b/FrontEnd/src/components/InPortal.tsx
@@ -0,0 +1,14 @@
+import { ReactNode } from "react";
+import ReactDOM from "react-dom";
+
+const optionalPortalElement = window.document.getElementById("portal");
+if (optionalPortalElement == null) {
+  throw Error("No portal element found.");
+}
+
+const portalElement = optionalPortalElement;
+
+export default function InPortal({ children }: { children: ReactNode }) {
+  return ReactDOM.createPortal(<>{children}</>, portalElement);
+}
+
-- 
cgit v1.2.3

