itizawa 6 лет назад
Родитель
Сommit
2e53907d3a
1 измененных файлов с 14 добавлено и 7 удалено
  1. 14 7
      src/client/js/components/PageComment/Comment.jsx

+ 14 - 7
src/client/js/components/PageComment/Comment.jsx

@@ -26,7 +26,7 @@ import CommentControl from './CommentControl';
  * @class Comment
  * @class Comment
  * @extends {React.Component}
  * @extends {React.Component}
  */
  */
-class Comment extends React.Component {
+class Comment extends React.PureComponent {
 
 
   constructor(props) {
   constructor(props) {
     super(props);
     super(props);
@@ -62,13 +62,20 @@ class Comment extends React.Component {
     this.renderHtml();
     this.renderHtml();
   }
   }
 
 
-  componentWillReceiveProps(nextProps) {
-    this.renderHtml(nextProps.comment.comment);
-  }
+  componentDidUpdate(prevProps) {
+    const { comment: prevComment } = prevProps;
+    const { comment } = this.props;
+
+    // render only when props.markdown is updated
+    if (comment !== prevComment) {
+      this.initCurrentRenderingContext();
+      this.renderHtml();
+      return;
+    }
+
+    const { interceptorManager } = this.props.appContainer;
 
 
-  // not used
-  setMarkdown(markdown) {
-    this.renderHtml(markdown);
+    interceptorManager.process('postRenderCommentHtml', this.currentRenderingContext);
   }
   }
 
 
   checkPermissionToControlComment() {
   checkPermissionToControlComment() {