1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/public/js/components/ErrorMessages.jsx
Ivar Conradi Østhus f82be4655a Added ErrorStore
2020-02-20 08:30:22 +01:00

39 lines
879 B
JavaScript

var React = require('react');
var Ui = require('./ErrorMessages.ui');
var ErrorStore = require('../stores/ErrorStore');
var ErrorActions = require('../stores/ErrorActions');
var ErrorMessages = React.createClass({
getInitialState: function() {
return {
errors: ErrorStore.getErrors()
};
},
onStoreChange: function() {
this.setState({
errors: ErrorStore.getErrors()
});
},
componentDidMount: function() {
this.unsubscribe = ErrorStore.listen(this.onStoreChange);
},
componentWillUnmount: function() {
this.unsubscribe();
},
onClearErrors: function() {
ErrorActions.clear();
},
render: function() {
return (
<Ui errors={this.state.errors} onClearErrors={this.onClearErrors}></Ui>
);
}
});
module.exports = ErrorMessages;