react-bootstrap
Version:
Bootstrap 3 components build with React
34 lines (28 loc) • 767 B
JavaScript
/** @jsx React.DOM */
var AlertAutoDismissable = React.createClass({
getInitialState: function() {
return {
alertVisible: false
};
},
render: function() {
if (this.state.alertVisible) {
return (
<Alert bsStyle="danger" onDismiss={this.handleAlertDismiss} dismissAfter={2000}>
<h4>Oh snap! You got an error!</h4>
<p>But this will hide after 2 seconds.</p>
</Alert>
);
}
return (
<Button onClick={this.handleAlertShow}>Show Alert</Button>
);
},
handleAlertDismiss: function() {
this.setState({alertVisible: false});
},
handleAlertShow: function() {
this.setState({alertVisible: true});
}
});
React.renderComponent(<AlertAutoDismissable />, mountNode);