瀏覽代碼

update PageCommentList.tsx method

yuto-oweseek 4 年之前
父節點
當前提交
c6756ea6e9
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      packages/app/src/components/PageCommentList.tsx

+ 3 - 1
packages/app/src/components/PageCommentList.tsx

@@ -94,8 +94,10 @@ const PageCommentList:FC<Props> = memo((props:Props):JSX.Element => {
   }
 
   const highlightComment = (comment: string):string => {
+    if (highlightKeywords == null) return comment;
+
     let highlightedComment = '';
-    highlightKeywords?.forEach((highlightKeyword) => {
+    highlightKeywords.forEach((highlightKeyword) => {
       highlightedComment = comment.replaceAll(highlightKeyword, '<em class="highlighted-keyword">$&</em>');
     });
     return highlightedComment;