import { Flex } from "rebass/styled-components"; import styled from "styled-components"; import React, { FC } from "react"; import ReactDOM from "react-dom"; import Animation from "./Animation"; interface Props extends React.ComponentProps { show: boolean; id?: string; closeHandler?: () => unknown; } const Wrapper = styled.div` position: fixed; width: 100%; height: 100%; top: 0; left: 0; display: flex; justify-content: center; align-items: center; background-color: rgba(50, 50, 50, 0.8); z-index: 1000; `; const Modal: FC = ({ children, id, show, closeHandler, ...rest }) => { if (!show) return null; const onClickOutside = (e) => { if (e.target.id === id) closeHandler(); }; return ReactDOM.createPortal( {children} , document.body ); }; Modal.defaultProps = { show: false }; export default Modal;