Skip to content

Instantly share code, notes, and snippets.

@chiefGui
Last active February 22, 2017 15:13
Show Gist options
  • Save chiefGui/018cb7db91804677c38faed226ed118d to your computer and use it in GitHub Desktop.
Save chiefGui/018cb7db91804677c38faed226ed118d to your computer and use it in GitHub Desktop.
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