// @flow import React from 'react'; import { connect } from 'react-redux'; import { closeNotification } from 'actions/notifications'; import type { Notification } from 'actions/notifications'; function NotificationRow(props: { notification: Notification, onClose: (n: Notification) => void }) { const { msg, level } = props.notification; let klass = ''; switch (level) { case 'danger': klass = 'alert-danger'; break; case 'success': klass = 'alert-success'; break; case 'warning': klass = 'alert-warning'; break; } return (
{level}
props.onClose(props.notification)} />
); } export class Notifications extends React.Component { props: { notifications: Notification[], closeNotification: (n: Notification) => void }; render() { if (!this.props.notifications.length) { return null; } return (
{this.props.notifications.map((n, i) => )}
); } } const mapStateToProps = state => ({ notifications: state.notifications }); export default connect(mapStateToProps, { closeNotification })(Notifications);