1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/packages/unleash-frontend/public/js/components/ErrorMessages.jsx

40 lines
843 B
React
Raw Normal View History

2016-06-18 21:53:18 +02:00
'use strict';
const React = require('react');
const Ui = require('./ErrorMessages.ui');
const ErrorStore = require('../stores/ErrorStore');
const ErrorActions = require('../stores/ErrorActions');
2014-10-30 18:25:38 +01:00
2016-06-18 21:53:18 +02:00
const ErrorMessages = React.createClass({
getInitialState() {
2015-03-17 20:29:03 +01:00
return {
errors: ErrorStore.getErrors()
};
},
2016-06-18 21:53:18 +02:00
onStoreChange() {
2015-03-17 20:29:03 +01:00
this.setState({
errors: ErrorStore.getErrors()
});
},
2016-06-18 21:53:18 +02:00
componentDidMount() {
2015-03-17 20:29:03 +01:00
this.unsubscribe = ErrorStore.listen(this.onStoreChange);
},
2014-10-30 18:25:38 +01:00
2016-06-18 21:53:18 +02:00
componentWillUnmount() {
2015-03-17 20:29:03 +01:00
this.unsubscribe();
},
2014-10-30 18:25:38 +01:00
2016-06-18 21:53:18 +02:00
onClearErrors() {
2015-03-17 20:29:03 +01:00
ErrorActions.clear();
},
2016-06-18 21:53:18 +02:00
render() {
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;