通用评论

index.js 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. page,
  18. loading,
  19. isNoMoreComment,
  20. sGetComment
  21. } = this.props.app;
  22. const spinning = Boolean(loading.sGetComment || loading.sCommentFavor);
  23. return (
  24. <div>
  25. <Spin spinning={spinning}>
  26. {list.map(item => (
  27. <CommentBox content={item} key={item.id} commentId={item.id} />
  28. ))}
  29. {!isNoMoreComment && (
  30. <div
  31. className="showMore"
  32. onClick={() => sGetComment({ page: page + 1 })}
  33. >
  34. <span>查看更多评论</span>
  35. </div>
  36. )}
  37. </Spin>
  38. </div>
  39. );
  40. }
  41. }
  42. CommentList.propTypes = {};
  43. export default Comment(CommentList);