forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (31 loc) · 984 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React from 'react';
import { connect } from 'react-redux';
import { actions } from 'reducers';
import { classes } from 'common/util';
import styles from './ToastContainer.module.scss';
class ToastContainer extends React.Component {
componentWillReceiveProps(nextProps) {
const newToasts = nextProps.toast.toasts.filter(toast => !this.props.toast.toasts.includes(toast));
newToasts.forEach(toast => {
window.setTimeout(() => this.props.hideToast(toast.id), 3000);
});
}
render() {
const { className } = this.props;
const { toasts } = this.props.toast;
return (
<div className={classes(styles.toast_container, className)}>
{
toasts.map(toast => (
<div className={classes(styles.toast, styles[toast.type])} key={toast.id}>
{toast.message}
</div>
))
}
</div>
);
}
}
export default connect(({ toast }) => ({ toast }), actions)(
ToastContainer,
);