feat(modals): add portal to display modals in

- feat(_document): render portals in the div element with id browser_extension

- feat(ModalPortal): useReactDom.createPortal to render childrens
This commit is contained in:
Aminejv 2021-09-15 18:40:51 +01:00 committed by Martina
parent 647b4d043a
commit 0c4ecd9025
2 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,14 @@
import * as React from "react";
import * as ReactDOM from "react-dom";
export const ModalPortal = ({ children }) => {
const [mounted, setMounted] = React.useState(false);
React.useEffect(() => {
setMounted(true);
return () => setMounted(false);
}, []);
return mounted ? ReactDOM.createPortal(children, document.getElementById("modals_portal")) : null;
};

View File

@ -15,6 +15,7 @@ class MyDocument extends Document {
* e.g. if the extension is installed on the user's browser, it will add 'isDownloaded' to className*/}
<div id="browser_extension" />
<Main />
<div id="modals_portal" />
<NextScript />
</body>
</Html>