Преглед на файлове

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>
                   ) }