通用评论

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