From 80cbf5baea5fdc46f1907db8b4cab236160be994 Mon Sep 17 00:00:00 2001 From: abg3000 Date: Sat, 27 Jul 2024 01:07:24 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20?= =?UTF-8?q?=EC=9E=90=EC=B2=B4=20=EC=83=81=ED=83=9C=EA=B0=92=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web-domains/src/common/components/Modal/Modal.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/web-domains/src/common/components/Modal/Modal.tsx b/packages/web-domains/src/common/components/Modal/Modal.tsx index fbecb2e8..1fdcf671 100644 --- a/packages/web-domains/src/common/components/Modal/Modal.tsx +++ b/packages/web-domains/src/common/components/Modal/Modal.tsx @@ -12,13 +12,11 @@ export interface ModalProps extends HTMLAttributes { } export const Modal = ({ isOpen, width, onClose, children, footer, ...rest }: PropsWithChildren) => { - const [modalState, setIsModalState] = useState(isOpen); const [element, setElement] = useState(null); const modalWidth = width ? `${width}px` : '100%'; const handleClose = () => { - setIsModalState(false); onClose?.(); }; @@ -27,7 +25,7 @@ export const Modal = ({ isOpen, width, onClose, children, footer, ...rest }: Pro }, []); useEffect(() => { - if (modalState) { + if (isOpen) { document.body.style.overflow = 'hidden'; } else { document.body.style.overflow = 'auto'; @@ -36,7 +34,7 @@ export const Modal = ({ isOpen, width, onClose, children, footer, ...rest }: Pro return () => { document.body.style.overflow = 'auto'; }; - }, [modalState]); + }, [isOpen]); if (typeof window === 'undefined') { return <>; @@ -46,7 +44,7 @@ export const Modal = ({ isOpen, width, onClose, children, footer, ...rest }: Pro return <>; } - if (!modalState) { + if (!isOpen) { return null; }