Skip to content

Commit

Permalink
fix: react-modal unmount bug
Browse files Browse the repository at this point in the history
  • Loading branch information
honeymaro committed Jan 11, 2023
1 parent 34f7220 commit 1564677
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ function Modal({
};
}, [resizeTrigger]);

useEffect(() => {
const removeClassName = () => {
if (!document.querySelector(".ReactModal__Content")) {
document.body.classList.remove("ReactModal__Body--open");
}
};
return () => {
removeClassName();
setTimeout(removeClassName, MODAL_CLOSE_TIMEOUT_MS + 100);
};
}, [isOpen]);

return (
<ReactModal
isOpen={resizeTrigger ? false : isOpen}
Expand Down

0 comments on commit 1564677

Please sign in to comment.