|
@@ -1,7 +1,5 @@
|
|
import React from 'react';
|
|
import React from 'react';
|
|
-import createReactClass from 'create-react-class';
|
|
|
|
import {ThemeProvider} from 'emotion-theming';
|
|
import {ThemeProvider} from 'emotion-theming';
|
|
-import Reflux from 'reflux';
|
|
|
|
|
|
|
|
import AlertStore from 'app/stores/alertStore';
|
|
import AlertStore from 'app/stores/alertStore';
|
|
import {lightTheme} from 'app/utils/theme';
|
|
import {lightTheme} from 'app/utils/theme';
|
|
@@ -14,19 +12,24 @@ type State = {
|
|
alerts: Array<Alert>;
|
|
alerts: Array<Alert>;
|
|
};
|
|
};
|
|
|
|
|
|
-const Alerts = createReactClass<Props, State>({
|
|
|
|
- displayName: 'Alerts',
|
|
|
|
- mixins: [Reflux.connect(AlertStore, 'alerts') as any],
|
|
|
|
|
|
+class Alerts extends React.Component<Props, State> {
|
|
|
|
+ state = this.getInitialState();
|
|
|
|
|
|
- getInitialState() {
|
|
|
|
|
|
+ getInitialState(): State {
|
|
return {
|
|
return {
|
|
- alerts: [],
|
|
|
|
|
|
+ alerts: AlertStore.getInitialState() as Alert[],
|
|
};
|
|
};
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ componentWillUnmount() {
|
|
|
|
+ this.unlistener?.();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ unlistener = AlertStore.listen((alerts: Alert[]) => this.setState({alerts}), undefined);
|
|
|
|
|
|
render() {
|
|
render() {
|
|
const {className} = this.props;
|
|
const {className} = this.props;
|
|
- const alerts = this.state.alerts as Array<Alert>;
|
|
|
|
|
|
+ const {alerts} = this.state;
|
|
return (
|
|
return (
|
|
<ThemeProvider theme={lightTheme}>
|
|
<ThemeProvider theme={lightTheme}>
|
|
<div className={className}>
|
|
<div className={className}>
|
|
@@ -36,7 +39,7 @@ const Alerts = createReactClass<Props, State>({
|
|
</div>
|
|
</div>
|
|
</ThemeProvider>
|
|
</ThemeProvider>
|
|
);
|
|
);
|
|
- },
|
|
|
|
-});
|
|
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
export default Alerts;
|
|
export default Alerts;
|