mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-06 00:07:44 +01:00
40 lines
859 B
JavaScript
40 lines
859 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} />
|
|
);
|
|
},
|
|
});
|
|
|
|
module.exports = ErrorMessages;
|