diff options
author | crupest <crupest@outlook.com> | 2023-09-21 17:45:06 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-09-21 17:45:21 +0800 |
commit | ffe0ef6dc532f5bf0226e074f95a351b36c5abbd (patch) | |
tree | f4437b59c982980b94088aebd38039635b54b58a /FrontEnd/src/components/InPortal.tsx | |
parent | 4bedca2bf5f3a6aaef004e7a85a9bfab4a9deede (diff) | |
download | timeline-ffe0ef6dc532f5bf0226e074f95a351b36c5abbd.tar.gz timeline-ffe0ef6dc532f5bf0226e074f95a351b36c5abbd.tar.bz2 timeline-ffe0ef6dc532f5bf0226e074f95a351b36c5abbd.zip |
...
Diffstat (limited to 'FrontEnd/src/components/InPortal.tsx')
-rw-r--r-- | FrontEnd/src/components/InPortal.tsx | 14 |
1 files changed, 14 insertions, 0 deletions
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); +} + |