From 0808f97fb59c5c30537b98494c07b60eb61dcaeb Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 18 Aug 2017 16:40:42 +0700 Subject: [PATCH] Consider state when optimizing comment --- client/coral-embed-stream/src/components/Comment.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/coral-embed-stream/src/components/Comment.js b/client/coral-embed-stream/src/components/Comment.js index dcc52d85a..5a2572574 100644 --- a/client/coral-embed-stream/src/components/Comment.js +++ b/client/coral-embed-stream/src/components/Comment.js @@ -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; }