Last active
November 27, 2018 15:00
-
-
Save dsternlicht/2a2ad114fe57fdc9cff44feca1c0e59d to your computer and use it in GitHub Desktop.
Using the React Modal component
This file contains hidden or 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 React, { Component } from 'react'; | |
| import Modal from './modal/modal'; | |
| import './app.css'; | |
| class App extends Component { | |
| state = { | |
| showModal: false | |
| } | |
| toggleModal = () => { | |
| this.setState({ | |
| showModal: !this.state.showModal | |
| }); | |
| } | |
| render() { | |
| return ( | |
| <div className="app"> | |
| <button className="modal_opener" onClick={this.toggleModal}> | |
| Click Me! I Do Not Bite... <span role="img" aria-label="emoji">😛</span> | |
| </button> | |
| <Modal | |
| show={this.state.showModal} | |
| closeCallback={this.toggleModal} | |
| customClass="custom_modal_class" | |
| > | |
| <React.Fragment> | |
| <h2>Told Ya!</h2> | |
| <iframe title="giphy" src="https://giphy.com/embed/l52CGyJ4LZPa0" width="480" height="273" frameBorder="0" className="giphy-embed" allowFullScreen></iframe><p><a href="https://giphy.com/gifs/sandler-sentences-sounding-l52CGyJ4LZPa0">via GIPHY</a></p> | |
| </React.Fragment> | |
| </Modal> | |
| </div> | |
| ); | |
| } | |
| } | |
| export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment