1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/packages/unleash-frontend/public/js/components/ErrorMessages.jsx

39 lines
879 B
React
Raw Normal View History

2015-03-17 20:29:03 +01:00
var React = require('react');
var Ui = require('./ErrorMessages.ui');
var ErrorStore = require('../stores/ErrorStore');
var ErrorActions = require('../stores/ErrorActions');
2014-10-30 18:25:38 +01:00
var ErrorMessages = React.createClass({
2015-03-17 20:29:03 +01:00
getInitialState: function() {
return {
errors: ErrorStore.getErrors()
};
},
onStoreChange: function() {
this.setState({
errors: ErrorStore.getErrors()
});
},
componentDidMount: function() {
this.unsubscribe = ErrorStore.listen(this.onStoreChange);
},
2014-10-30 18:25:38 +01:00
2015-03-17 20:29:03 +01:00
componentWillUnmount: function() {
this.unsubscribe();
},
2014-10-30 18:25:38 +01:00
2015-03-17 20:29:03 +01:00
onClearErrors: function() {
ErrorActions.clear();
},
render: function() {
2014-10-30 18:25:38 +01:00
return (
2015-03-17 20:29:03 +01:00
<Ui errors={this.state.errors} onClearErrors={this.onClearErrors}></Ui>
2014-10-30 18:25:38 +01:00
);
}
});
2014-10-31 10:30:23 +01:00
module.exports = ErrorMessages;