Skip to content

Instantly share code, notes, and snippets.

@chiefGui
Last active February 22, 2017 12:14
Show Gist options
  • Save chiefGui/2f9d8bbf102615df1d9440f5115ac873 to your computer and use it in GitHub Desktop.
Save chiefGui/2f9d8bbf102615df1d9440f5115ac873 to your computer and use it in GitHub Desktop.
import React, {Component, PropTypes} from 'react'
class Modal extends Component {
state = {isOpen: false}
static propTypes = {
isOpen: PropTypes.bool
}
componentWillMount() {
this.setState({isOpen: this.props.isOpen})
}
renderContent () {
return (
<div id="modal">
<form>
<input type="text" placeholder="Your e-mail" />
<textarea placeholder="What are your thoughts?" />
<button onClick={this.setState({isOpen: false})}>Close</button>
<button>Send</button>
</form>
</div>
)
}
render () {
{isOpen} = this.state
return isOpen ? this.renderContent() : null
}
}
export default Modal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment