Skip to content

Commit

Permalink
fix(modal): prevent modal double rendering (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
victorgcramos authored Sep 29, 2022
1 parent 8d54b80 commit 9006f9f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/Modal/Modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const modalRoot = document.createElement("div");
modalRoot.setAttribute("id", "modal-root");
document.body.appendChild(modalRoot);

const el = document.createElement("div");

// TODO: use svg icons when we have them
const Modal = ({
style,
Expand All @@ -33,7 +35,6 @@ const Modal = ({
disableDismiss,
...props
}) => {
const el = document.createElement("div");
useEffect(() => {
modalRoot.appendChild(el);
return () => modalRoot.removeChild(el);
Expand All @@ -54,6 +55,7 @@ const Modal = ({
handleCloseModal();
}
}, [escPressed, handleCloseModal]);

return createPortal(
<ModalWrapper
show={show}
Expand Down

0 comments on commit 9006f9f

Please sign in to comment.