import React from 'react';
import { connect } from 'react-redux';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import * as appPropTypes from './appPropTypes';
import * as stateActions from '../redux/stateActions';
import { Appear } from './transitions';
const Notifications = ({ notifications, onClick }) => {
console.log("notifications", notifications);
return (
聊天
{
notifications.map((notification) => {
return (
{
// 类型是否是用户发送的消息
notification.type == 'userMessage' ?
{
notification.isMe ?
:
<>
用户-{notification.id}
{notification.text}
>
}
:
{notification.text}
}
// 信息提示动画
//
// onClick(notification.id)}
// >
//
//
//
// {notification.title}
//
//
{notification.text}
//
//
//
);
})
}
);
};
Notifications.propTypes =
{
notifications: PropTypes.arrayOf(appPropTypes.Notification).isRequired,
onClick: PropTypes.func.isRequired
};
const mapStateToProps = (state) => {
const { notifications } = state;
return { notifications };
};
const mapDispatchToProps = (dispatch) => {
return {
onClick: (notificationId) => {
dispatch(stateActions.removeNotification(notificationId));
}
};
};
const NotificationsContainer = connect(
mapStateToProps,
mapDispatchToProps
)(Notifications);
export default NotificationsContainer;