通用评论

index.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import React, { Component } from "react";
  2. import { Spin } from "antd";
  3. import Comment from "../../Comment";
  4. import CommentBox from "../CommentBox";
  5. import "./index.css";
  6. class CommentList extends Component {
  7. constructor(props) {
  8. super(props);
  9. this.state = {};
  10. }
  11. componentWillMount() {
  12. this.props.app.sGetComment();
  13. }
  14. render() {
  15. const {
  16. list,
  17. total,
  18. page,
  19. loading,
  20. isNoMoreComment,
  21. sGetComment
  22. } = this.props.app;
  23. const spinning = Boolean(
  24. loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor
  25. );
  26. return (
  27. <div>
  28. <Spin spinning={spinning}>
  29. <div>共 {total} 条评论</div>
  30. {list.map(item => (
  31. <CommentBox content={item} key={item.id} commentId={item.id} />
  32. ))}
  33. {!isNoMoreComment &&
  34. list.length !== total && (
  35. <div
  36. className="comment-list-show-more"
  37. onClick={() => sGetComment({ page: page + 1 })}
  38. >
  39. <span>查看更多评论</span>
  40. </div>
  41. )}
  42. </Spin>
  43. </div>
  44. );
  45. }
  46. }
  47. CommentList.propTypes = {};
  48. export default Comment(CommentList);