From d4ca02f1108e20a412b09cc47ef2e334d3310f7e Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Tue, 18 Aug 2020 23:35:26 -0700 Subject: [PATCH] Use portal for modals. Prisma disconnect after query. --- components/common/Modal.js | 6 ++++-- components/layout/Layout.js | 1 + components/layout/MenuLayout.module.css | 5 ----- lib/db.js | 11 +++++++---- lib/session.js | 3 ++- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/components/common/Modal.js b/components/common/Modal.js index c2bca43f..42df57e2 100644 --- a/components/common/Modal.js +++ b/components/common/Modal.js @@ -1,16 +1,18 @@ import React from 'react'; +import ReactDOM from 'react-dom'; import { useSpring, animated } from 'react-spring'; import styles from './Modal.module.css'; export default function Modal({ title, children }) { const props = useSpring({ opacity: 1, from: { opacity: 0 } }); - return ( + return ReactDOM.createPortal(
{title &&
{title}
}
{children}
-
+ , + document.getElementById('__modals'), ); } diff --git a/components/layout/Layout.js b/components/layout/Layout.js index 1285f2c3..021745cc 100644 --- a/components/layout/Layout.js +++ b/components/layout/Layout.js @@ -16,6 +16,7 @@ export default function Layout({ title, children, header = true, footer = true } {header &&
}
{children}
+
{footer &&