Last active
May 13, 2021 16:29
-
-
Save mahdidavoodi7/9cd9863de2214fd46032b9f2a12f0494 to your computer and use it in GitHub Desktop.
First modal example App.js
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 { useState } from "react"; | |
import "./App.css"; | |
function App() { | |
const [isOpen, setOpen] = useState(false); | |
return ( | |
<div className="container"> | |
<button onClick={() => setOpen(true)} className="open-btn"> | |
Open Modal | |
</button> | |
<div | |
onClick={() => setOpen(false)} | |
className={`underlay ${isOpen ? "open" : ""}`} | |
/> | |
<div className={`modal ${isOpen ? "open" : ""}`}></div> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment