Просмотр исходного кода

update PageCommentList.tsx method

yuto-oweseek 4 лет назад
Родитель
Сommit
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;