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 { PureComponent } from 'react'; export default class CommentList extends ImmutablePureComponent { static propTypes = { commentsLimited: PropTypes.bool, descendants: ImmutablePropTypes.list, onViewComments: PropTypes.func.isRequired, } render() { const { descendants, commentsLimited, onViewComments } = this.props const size = descendants.size const upperLimit = commentsLimited ? 6 : size const max = Math.min(commentsLimited ? 2 : upperLimit, size) console.log("size, max:", size, max) const Wrapper = !commentsLimited ? ScrollableList : DummyContainer return (
{ descendants.slice(0, max).map((descendant, i) => ( )) } { size > 0 && size > max && commentsLimited &&
{max}  of  {size}
}
) } } class DummyContainer extends PureComponent { render() { return
{this.props.children}
} }