Created
September 18, 2021 15:30
-
-
Save SafaElmali/8689b28bdf36887364d203c973f99c3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "../styles/modal.css"; | |
import { createPortal } from "react-dom"; | |
const ModalWithPortal = ({ | |
isOpenPortal, | |
setIsOpenPortal, | |
productName = "", | |
}) => { | |
if (!isOpenPortal) return null; | |
return createPortal( | |
<div className="modal-container"> | |
<div className="modal-header"> | |
<h1>{productName}</h1> | |
</div> | |
<button onClick={() => setIsOpenPortal(false)}>Close modal</button> | |
</div>, | |
document.getElementById("basket-item") | |
); | |
}; | |
export default ModalWithPortal; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment