react-bootstrap
Version:
Bootstrap 3 components build with React
38 lines (32 loc) • 1.05 kB
JavaScript
/** @jsx React.DOM */
var AlertDismissable = React.createClass({
getInitialState: function() {
return {
alertVisible: true
};
},
render: function() {
if (this.state.alertVisible) {
return (
<Alert bsStyle="danger" onDismiss={this.handleAlertDismiss}>
<h4>Oh snap! You got an error!</h4>
<p>Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.</p>
<p>
<Button bsStyle="danger">Take this action</Button> or
<Button onClick={this.handleAlertDismiss}>Hide Alert</Button>
</p>
</Alert>
);
}
return (
<Button onClick={this.handleAlertShow}>Show Alert</Button>
);
},
handleAlertDismiss: function() {
this.setState({alertVisible: false});
},
handleAlertShow: function() {
this.setState({alertVisible: true});
}
});
React.renderComponent(<AlertDismissable />, mountNode);