Skip to content

Instantly share code, notes, and snippets.

@BrockReece
Created November 1, 2015 12:02
Show Gist options
  • Save BrockReece/7cff01614ac614fce745 to your computer and use it in GitHub Desktop.
Save BrockReece/7cff01614ac614fce745 to your computer and use it in GitHub Desktop.
React Bootstrap Modal using custom mixin of common modal functions
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