Created
November 1, 2015 12:02
-
-
Save BrockReece/7cff01614ac614fce745 to your computer and use it in GitHub Desktop.
React Bootstrap Modal using custom mixin of common modal functions
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
ModalMixin = { | |
getInitialState: function() { | |
return { showModal: false }; | |
}, | |
close: function() { | |
this.setState({ showModal: false }); | |
}, | |
open: function() { | |
this.setState({ showModal: true }); | |
}, | |
}; | |
var ModalExample = React.createClass({ | |
mixins: [ModalMixin], | |
render: function() { | |
return( | |
<span> | |
<ReactBootstrap.Button bsStyle="primary" onClick={this.open}> | |
Open modal | |
</ReactBootstrap.Button> | |
<ReactBootstrap.Modal show={this.state.showModal} onHide={this.close}> | |
<ReactBootstrap.Modal.Header closeButton> | |
<ReactBootstrap.Modal.Title>Modal Example</Modal.Title> | |
</ReactBootstrap.Modal.Header> | |
<ReactBootstrap.Modal.Body> | |
<h1>Hello World</h1> | |
</ReactBootstrap.Modal.Body> | |
</ReactBootstrap.Modal> | |
</span> | |
); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment