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
2020-02-20 08:30:27 +01:00

40 lines
866 B
JavaScript

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