Last active
February 22, 2017 15:13
-
-
Save chiefGui/018cb7db91804677c38faed226ed118d to your computer and use it in GitHub Desktop.
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 '../components/Modal' | |
class Home extends Component { | |
constructor () { | |
super() | |
this.openModal = this.openModal.bind(this) | |
this.closeModal = this.closeModal.bind(this) | |
} | |
state = {isContactModalOpen: false} | |
openModal() { | |
this.setState({isContactModalOpen: true}) | |
} | |
closeModal () { | |
this.setState({isContactModalOpen: false}) | |
} | |
render () { | |
const {isContactModalOpen} = this.state | |
return ( | |
<div> | |
{isContactModalOpen && <Modal onClose={this.closeModal} />} | |
<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.openModal}>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