import React from 'react' import PropTypes from 'prop-types' import ImmutablePropTypes from 'react-immutable-proptypes' import ImmutablePureComponent from 'react-immutable-pure-component' import Button from './button' import Comment from './comment' import ScrollableList from './scrollable_list' import Text from './text' import Dummy from './dummy' class CommentList extends ImmutablePureComponent { render() { const { descendants, commentsLimited, onViewComments, ancestorAccountId } = this.props const size = descendants.size const upperLimit = commentsLimited ? 6 : size const max = Math.min(commentsLimited ? 2 : upperLimit, size) const Wrapper = !commentsLimited ? ScrollableList : Dummy return ( { descendants.slice(0, max).map((descendant, i) => ( )) } { size > 0 && size > max && commentsLimited &&
{max}  of  {size}
}
) } } CommentList.propTypes = { commentsLimited: PropTypes.bool, descendants: ImmutablePropTypes.list, onViewComments: PropTypes.func.isRequired, ancestorAccountId: PropTypes.string.isRequired, } export default CommentList