Skip to content

Instantly share code, notes, and snippets.

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