Last active
February 22, 2017 12:06
-
-
Save chiefGui/8d5a2259544bddd8d1ae136655f06105 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 React, {Component} from 'react' | |
class Home extends Component { | |
state = {isContactModalOpen: false} | |
renderContactModal () { | |
return ( | |
<div id="modal"> | |
<form> | |
<input type="text" placeholder="Your e-mail" /> | |
<textarea placeholder="What are your thoughts?" /> | |
<button onClick={this.setState({isContactModalOpen: false})}>Close</button> | |
<button>Send</button> | |
</form> | |
</div> | |
) | |
} | |
render () { | |
const {isContactModalOpen} = this.state | |
return ( | |
<div> | |
{isContactModalOpen ? this.renderContactModal() : null} | |
<h1>Hello world!</h1> | |
<hr /> | |
<p>What a beautiful day to learn about React's state—don't you think?</p> | |
<hr /> | |
<button onClick={this.setState({isContactModalOpen: true})}>Get in touch</button> | |
</div> | |
) | |
} | |
} | |
export default Home |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment