Consider state when optimizing comment

This commit is contained in:
Chi Vinh Le
2017-08-18 16:40:42 +07:00
parent af4b01c2ae
commit 0808f97fb5
@@ -124,14 +124,14 @@ export default class Comment extends React.Component {
}
}
shouldComponentUpdate(next) {
shouldComponentUpdate(nextProps, nextState) {
// Specifically handle `activeReplyBox` if it is the only change.
const changes = getShallowChanges(this.props, next);
const changes = [...getShallowChanges(this.props, nextProps), ...getShallowChanges(this.state, nextState)];
if (changes.length === 1 && changes[0] === 'activeReplyBox') {
if (
!containsCommentId(this.props, this.props.activeReplyBox) &&
!containsCommentId(next, next.activeReplyBox)
!containsCommentId(nextProps, nextProps.activeReplyBox)
) {
return false;
}