mirror of
https://github.com/ascribe/onion.git
synced 2025-01-05 11:25:09 +01:00
40 lines
738 B
JavaScript
40 lines
738 B
JavaScript
|
import React from 'react';
|
||
|
|
||
|
import Alert from 'react-bootstrap/lib/Alert';
|
||
|
|
||
|
|
||
|
const { node } = React.PropTypes;
|
||
|
|
||
|
const AlertDismissable = React.createClass({
|
||
|
propTypes: {
|
||
|
error: node.isRequired
|
||
|
},
|
||
|
|
||
|
getInitialState() {
|
||
|
return {
|
||
|
alertVisible: true
|
||
|
};
|
||
|
},
|
||
|
|
||
|
show() {
|
||
|
this.setState({ alertVisible: true });
|
||
|
},
|
||
|
|
||
|
hide() {
|
||
|
this.setState({ alertVisible: false });
|
||
|
},
|
||
|
|
||
|
render() {
|
||
|
const { error } = this.props;
|
||
|
const { alertVisible } = this.state;
|
||
|
|
||
|
return alertVisible ? (
|
||
|
<Alert bsStyle='danger' onDismiss={this.hide}>
|
||
|
{error}
|
||
|
</Alert>
|
||
|
) : null;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
export default AlertDismissable;
|