소스 검색

restrict count badge props to only number

yuken 4 년 전
부모
커밋
45783e737d
2개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 1
      packages/app/src/components/Common/CountBadge.tsx
  2. 2 2
      packages/app/src/components/Page/DisplaySwitcher.tsx

+ 1 - 1
packages/app/src/components/Common/CountBadge.tsx

@@ -1,7 +1,7 @@
 import React, { FC } from 'react';
 
 type CountProps = {
-  count: number | null | undefined
+  count: number
 }
 
 const CountBadge: FC<CountProps> = (props:CountProps) => {

+ 2 - 2
packages/app/src/components/Page/DisplaySwitcher.tsx

@@ -78,7 +78,7 @@ const DisplaySwitcher = (): JSX.Element => {
                           <PageListIcon />
                         </div>
                         {t('page_list')}
-                        <CountBadge count={pagingResult?.totalCount} />
+                        {pagingResult != null && <CountBadge count={pagingResult.totalCount} />}
                       </button>
                     ) }
                   </div>
@@ -93,7 +93,7 @@ const DisplaySwitcher = (): JSX.Element => {
                       >
                         <i className="icon-fw icon-bubbles grw-page-accessories-control-icon"></i>
                         <span>Comments</span>
-                        <CountBadge count={comments != null ? comments.length : 0} />
+                        {comments != null && <CountBadge count={comments.length} />}
                       </button>
                     </div>
                   ) }