import React, { useContext, useEffect } from "react"; import classnames from "classnames"; import { NotificationContext } from "context/notification"; const baseClass = "modal"; export interface IModalProps { children: JSX.Element; onExit: () => void; title: string | JSX.Element; className?: string; } const Modal = ({ children, onExit, title, className, }: IModalProps): JSX.Element => { const { hideFlash } = useContext(NotificationContext); useEffect(() => { const closeWithEscapeKey = (e: KeyboardEvent) => { if (e.key === "Escape") { onExit(); } }; hideFlash(); document.addEventListener("keydown", closeWithEscapeKey); return () => { document.removeEventListener("keydown", closeWithEscapeKey); }; }, []); const modalContainerClassName = classnames( `${baseClass}__modal_container`, className ); return (