Clean up AlertDismissable and move to root components folder

This commit is contained in:
Brett Sun 2016-07-11 19:05:20 +02:00
parent d5469b3efa
commit 61779e5535
2 changed files with 39 additions and 39 deletions

View File

@ -0,0 +1,39 @@
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;

View File

@ -1,39 +0,0 @@
'use strict';
import React from 'react';
import Alert from 'react-bootstrap/lib/Alert';
let AlertDismissable = React.createClass({
propTypes: {
error: React.PropTypes.array.isRequired
},
getInitialState() {
return {
alertVisible: true
};
},
show() {
this.setState({alertVisible: true});
},
hide() {
this.setState({alertVisible: false});
},
render() {
if (this.state.alertVisible) {
return (
<Alert bsStyle='danger' onDismiss={this.hide}>
{this.props.error}
</Alert>
);
}
return (
<span />
);
}
});
export default AlertDismissable;